Solved

Response.Redirect not working in Global.asax

Posted on 2013-06-29
3
2,725 Views
Last Modified: 2013-07-27
Hi,

i am working on ASP.net 2.0 using c#

Response.Redirect() to new url on different domain is not working from global.ascx.

HttpContext.Current.Response.Redirect("http://www.mynewdomain/myfile.aspx", true) is not working from global.ascx.

But it works from any user control.

Please advise.

Regards,
0
Comment
Question by:tia_kamakshi
3 Comments
 
LVL 16

Assisted Solution

by:Easwaran Paramasivam
Easwaran Paramasivam earned 250 total points
ID: 39287836
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39287838
Hi,
maybe a typo but do you mean global.asax?
In which event did you add your redirect code?
If you want to redirect any request to this web app to another url, then either use a web.config redirect or configure IIS to redirect.
HTH
Rainer
0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 250 total points
ID: 39320445
Hi....

Replace Response.Redirect("~/Error.aspx"); with:

// You've handled the error, so clear it. Leaving the server in an error state can cause unintended side effects as the server continues its attempts to handle the error.
Server.ClearError();

// Possible that a partially rendered page has already been written to response buffer before encountering error, so clear it.
Response.Clear();

// Finally redirect, transfer, or render a error view
Response.Redirect("~/Error.aspx");
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Set cookies HttpOnly and Secure 4 52
C# Application Local DB Connection String 23 59
ConsoleSql 1 17
dynamic menu in asp.net c# 11 27
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now