Response.Redirect not working in UpdatePanel

2.7k Views Asked by At

When calling a AsyncPostBackTrigger within an UpdatePanel I get the following error in Google Chrome console window:

Uncaught object ScriptResource.axd?d=YzEIJp7ym3ilJ-pArSjfZp5Fi4GhIdhZV-apQqYKJ9RoVqd3XZNre-FurXQ0crvFJTbHR_zBdWPLTG…:5
Error.create ScriptResource.axd?d=YzEIJp7ym3ilJ-pArSjfZp5Fi4GhIdhZV-apQqYKJ9RoVqd3XZNre-FurXQ0crvFJTbHR_zBdWPLTG…:5
Sys.WebForms.PageRequestManager._createPageRequestManagerParserError ScriptResource.axd?d=9tlN-lT3vnCZho9SnrriA72YbUKTo0FKsj2ZcC8Z_vczKR3tzEormmzRL4gbedwhxslHQci9lwVTXF…:5
Sys.WebForms.PageRequestManager._parseDelta ScriptResource.axd?d=9tlN-lT3vnCZho9SnrriA72YbUKTo0FKsj2ZcC8Z_vczKR3tzEormmzRL4gbedwhxslHQci9lwVTXF…:5
Sys.WebForms.PageRequestManager._onFormSubmitCompleted ScriptResource.axd?d=9tlN-lT3vnCZho9SnrriA72YbUKTo0FKsj2ZcC8Z_vczKR3tzEormmzRL4gbedwhxslHQci9lwVTXF…:5
(anonymous function) ScriptResource.axd?d=YzEIJp7ym3ilJ-pArSjfZp5Fi4GhIdhZV-apQqYKJ9RoVqd3XZNre-FurXQ0crvFJTbHR_zBdWPLTG…:5
(anonymous function) ScriptResource.axd?d=YzEIJp7ym3ilJ-pArSjfZp5Fi4GhIdhZV-apQqYKJ9RoVqd3XZNre-FurXQ0crvFJTbHR_zBdWPLTG…:5
Sys.Net.WebRequest.completed ScriptResource.axd?d=YzEIJp7ym3ilJ-pArSjfZp5Fi4GhIdhZV-apQqYKJ9RoVqd3XZNre-FurXQ0crvFJTbHR_zBdWPLTG…:5
_onReadyStateChange

I have a HttpModule which routes SEO friendly URL's to aspx files, without the routing the error doesn't appear.

    public void Init(HttpApplication application)
    {
        this.application = application;

        RegisterRoutes();

    }

    private static void RegisterRoutes()
    {
        if (RouteTable.Routes.Count > 0)
        {
            return;
        }

        RouteTable.Routes.Add(new Route("{resource}.axd", new StopRoutingHandler()));

        RouteTable.Routes.Add("Testing1",
            new Route("Testing1/{CID}/{FriendlyName}",
            new RedirectTest.Routing.TestRouteHandler("~/Default.aspx")));

        RouteTable.Routes.Add("Testing2",
            new Route("Testing2/{CID}/{FriendlyName}",
            new RedirectTest.Routing.TestRouteHandler("~/Default2.aspx")));
    }

I get the below HTTP Response body when I'm not using URL routing, which is probably the reason why its working:

69|dataItem||<script type="text/javascript">window.location="about:blank"</script>|14|pageRedirect||/Default2.aspx|

Why is the HTTP Response body different when using URL routing with an update panel?

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2fDefault2.aspx">here</a>.</h2>
</body></html>

Edit: As requested here is my page with the update panel:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RedirectTest._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" EnablePageMethods="true" ScriptMode="Release"></asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <a target=" " title="Click here to submit">
                    <asp:LinkButton ID="btnContinue" runat="server" OnClick="btnContinue_Click1" >
                        <asp:Image ID="btnContinueImg" runat="server" ImageUrl="http://www.techgeekguy.com/wp-content/uploads/2010/12/Free_Button-300x300.jpg" /></asp:LinkButton>                                                 
                </a>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnContinue" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
0

There are 0 best solutions below