简体   繁体   中英

Response.Redirect leading to custom Error.aspx page in asp.net

I have a web application where I am doing a Response.Redirect("Register.aspx") page in a button_click event. However, when I am step through this code, when the Response.Redirect("Register.aspx") statement executes... the browser becomes the active window & the status bar below says "waiting for response from localhost..." and then after 5 seconds the custom error page is displayed.

How can I debug this to see what is causing the error page to be displayed?

Since you said there is a pause, I'm assuming the redirect is working and you're hitting the issue on your Register.aspx page.

  1. Temporarily turn off custom errors to see the real exception message.
  2. Put exception handling in your Register.aspx page and log the error so you can view the exception messsage.
  3. Put exception handling in the Global.asax Application_Error method to catch all application errors and log it.
  4. Check the Event Viewer

You have several ways to check what's happening. To begin you can turn off custom errors in web.config, if not already done, and add, if not already present, the global application file Global.asax. This file defines the Application_Error method, in which you can set a breakpoint to see what happens.

See also: http://msdn.microsoft.com/en-us/library/24395wz3.aspx

您应该在计算机上某处以文本文件的形式保存日志,该日志已生成运行时错误消息。

u can try Response.Redirect("~/Register.aspx",false);

The second parameter prevent break of current thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM