Solved

Response.Redirect not working in Global.asax

Posted on 2013-06-29
3
3,004 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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