Object Moved to here

G

Guest

Hi Experts,

I am getting the following error when I do a Response.Redirect from an aspx
page to another aspx page. I am using the following code in my global.asax
Application_Error event to redirect to an error page.

Session["Error"] = Server.GetLastError();
Response.Redirect("Error.aspx");

However I am not able to go to the Error Page and am getting this error.

I am getting the error "Object Moved to Here". All other pages in the
application are working well. This is an error page which I added in an
already working application. I wrote code in the Global.asax to redirect to
the error page on an unhandled error.

I searched the web and somewhere I got an instruction to add the following
lines to the code

Response.Expires = 0;
Response.Buffer = true;
Response.Clear();

I added those lines but still am getting this error. I am getting the error
only in the production site and not in my development environment.

Can anyone please help me get out of this urgent issue.

Thanking you in advance

Regards
Ganesh
 
W

William F. Robertson, Jr.

Add Server.ClearError() to your Application_Error

Session["Error"] = Server.GetLastError();
Server.ClearError();
Response.Redirect( "Error.aspx" );

Couple things of note. Not all application errors have a Session context
attached to them. You probably want to check

if ( System.Web.HttpContext.Current != null )
{
System.Web.HttpContext.Current.Session["Error"] = Server.GetLastError();
}

HTH,

bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top