开发者

Visual Studio.NET 2010 debugging - how to stop execution when any Response.Redirect is hit

In my solution (partly c#, partly VB.NET), I am suspectin开发者_高级运维g that somewhere during the execution there is a Response.Redirect that I am unaware of that destroys my page context.

There are currently 218 Response.Redirects in my code. I have set breakpoints to the usual suspects, but I'd prefer a way to tell Visual Studio to stop whenever a line with Response.Redirect is hit. Is there a way? Or an alternate debugging practise?

A more generic version of that question would be: is there a way to add breakpoints to a solution through a Find action, similar to the "Bookmark All" button? Or to "convert" bookmarks to breakpoints?


IMHO the cleanest way would be to refactor the redirect functionality into a helper, and add your logging/debugging there where there's a single point.

If you just want something quick, you could turn on Exceptions in the debugging menu, and there should be a thread abort exception that you can break on.


In Visual Studio, go to Debug/New BreakPoint/Break at Function.... Type in System.Web.Response.Redirect.

Now the debugger will break whenever Redirect is called.

If you want a specific overload of Redirect, you can add the parameters, e.g., System.Web.Response.Redirect(string)`. See MSDN for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜