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
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
Server.Transfer("mywebpage.aspx") seems to work only when a session already exists.
If there is no Session started it throws this error so you must use Response.Redirect or another method.