Solved

Response.Redirect not working in Global.asax

Posted on 2013-06-29
3
2,801 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in query expression 3 37
Error on Add method 1 38
C# parent child form 5 20
C# guarantee sql connection close 6 32
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

21 Experts available now in Live!

Get 1:1 Help Now