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

后端 未结 8 1816
小蘑菇
小蘑菇 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 09:02

    I was hooking into the request pipeline in the OnPreRequestHandlerExecute event, and found I couldn't use Server.Transfer because it threw the same error as yours about executing a child request.

    Using HttpContext.Current.RewritePath didn't work because it seemed to be ignored and I wasn't redirected anywhere.

    If you're using IIS 7 and up, you can use Server.TransferRequest instead which did the trick for me.

    The differences between the two methods are covered in this answer: TransferRequest vs Transfer in ASP.Net

提交回复
热议问题