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

后端 未结 8 1815
小蘑菇
小蘑菇 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    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")
    

提交回复
热议问题