Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a HttpModule in C# 2.0 which handles exceptions thrown. Whenever the exception is thrown, an error page (aspx) with some querystring will be called. It is done through Server.Transfer().

But when the control tries to execute Server.Transfer(), the following exception is thrown:

Error executing child request for [pagename].aspx.

Whereas Request.Redirect() works fine.

I tried setting EnableViewStateMac="false" in Page directive of the page to which request is transferred. Still problem persists.

Here is the code I tried:

string errorPage = "errorpage.aspx?id=" + someErrorId
HttpContext.Current.Server.Transfer(errorPage,true);

Any idea how this can be resolved?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
698 views
Welcome To Ask or Share your Answers For Others

1 Answer

I found an alternative to Server.Transfer()

I used

 HttpContext.Current.RewritePath("somefile.aspx");

This solved the issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...