Server.Transfer throws Error executing child request. How to resolve?

后端 未结 8 1770
小蘑菇
小蘑菇 2020-12-17 08:36

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 i

相关标签:
8条回答
  • 2020-12-17 08:44

    It isn't a bug, it is by design. See http://support.microsoft.com/kb/320439

    0 讨论(0)
  • 2020-12-17 08:52

    I found an alternative to Server.Transfer()

    I used

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

    This solved the issue.

    0 讨论(0)
  • 2020-12-17 08:52

    I changed Server.Transfer for Server.TransferRequest, then I've got the real exception behind. It was a problem with a reference to an incorrect ReportViewer version.

    0 讨论(0)
  • 2020-12-17 08:55

    I had this same problem, and discovered it was to do with the relative paths of where the Server.Transfer is running and where you are redirecting to. In my case, this was executing in a sub-directory, so @ray's answer (adding ../ to the start of the URL) worked. However, when I then executed in the directory above, the same thing happened. Therefore, I changed to using a rooted path:

    Server.Transfer("~/errorpage.aspx")
    
    0 讨论(0)
  • 2020-12-17 08:56

    If you happen to see this exception occur in the VS.NET IDE during debug, go ahead at least once and press F5 to continue debugging. In my case, the actual page did render with the ASP.NET exception that was really causing the issue. In my case I had an incorrectly formatted asp:ChangePassword control that was actually causing the "Error executing child request" exception.

    0 讨论(0)
  • 2020-12-17 08:58

    My fix was different:

    An online query produced this Microsoft Knowledge Base article which stated the resolution would be to use Response.Redirect instead of Server.Transfer.

    I changed the command and got a more accurate "404 Error Message" instead of the cryptic "Error executing child request" message.

    That led me to inspect the redirect string and I noticed my path was off.

    I fixed the Transfer String from "ErrorPage.aspx" to "../ErrorPage.aspx" (notice the path change) and Server.Transfer worked just fine.

    0 讨论(0)
提交回复
热议问题