BUG: Postback Event Not Called When RewritePath Uses Server.Transfer or Server.Execute (817036)
The information in this article applies to:
- Microsoft ASP.NET (included with the .NET Framework 1.1)
SYMPTOMSWhen you use the Server.Transfer or the Server.Execute method along with HttpContext.RewritePath in an ASP.NET page to transfer control to another ASP.NET page,
the postback event on the receiving page is not raised.WORKAROUNDTo work around this problem, use one of these methods as
detailed following this list:
- Use Response.Redirect.
- Add the Context.Rewrite path
Use Response.RedirectUse Response.Redirect instead of Server.Transfer or context.Server.Execute in the ProcessRequest() method of HttpHandler. The modified ProcessRequest() method appears as follows: Microsoft Visual C# .NET Codepublic void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
string redirurl = Request.RawUrl.Replace ("test.ashx/", "");
context.RewritePath (redirurl);
Response.Redirect(redirurl);
} Microsoft Visual Basic .NET Code
Public Sub ProcessRequest(ByVal context As HttpContext) _
Implements IHttpHandler.ProcessRequest
Dim Request As HttpRequest = context.Request
Dim Response As HttpResponse = context.Response
Dim redirurl As String = Request.RawUrl.Replace("test.ashx/", "")
context.RewritePath(redirurl)
Response.Redirect(redirurl)
End Sub Add Context.Rewrite Add the Context.Rewrite path in Application_BeginRequest event of the Global.asax file. The modified Application_BeginRequest event appears as as follows:. Visual C# .NET Codeprotected void Application_BeginRequest(Object sender, EventArgs e)
{
string redirurl = Request.RawUrl.Replace ("test.ashx/", "");
this.Context.RewritePath(redirurl);
} Visual Basic .NET Code
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim redirurl As String
redirurl = Request.RawUrl.Replace("test.ashx/", "")
Me.Context.RewritePath(redirurl)
End Sub STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed at the beginning of this article.
REFERENCES For additional
information, click the following article numbers to view the articles in the
Microsoft Knowledge Base: 320439
PRB: "Error Executing Child Request" Error Message When You Use Server.Transfer or Server.Execute in ASP.NET Page
320976 PRB: Server.Transfer Allows Unauthorized Pages to Be Displayed
219294 How to Use the Server.Transfer Method
Modification Type: | Major | Last Reviewed: | 7/28/2003 |
---|
Keywords: | kbState kbWebForms kbweb kbbug KB817036 kbAudDeveloper |
---|
|