Response.Redirect在UpdatePanel中不起作用

时间:2014-05-29 10:26:01

标签: asp.net routing updatepanel httpmodule scriptresource.axd

在UpdatePanel中调用AsyncPostBackTrigger时,我在Google Chrome控制台窗口中收到以下错误:

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

我有一个HttpModule,它将SEO友好的URL路由到aspx文件,没有路由,错误没有出现。

    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")));
    }

当我使用URL路由时,我得到以下HTTP响应正文,这可能是其工作的原因:

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

为什么在使用带有更新面板的URL路由时,HTTP响应正文会有所不同?

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

修改:根据此处的要求,我的页面是更新面板:

<%@ 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 个答案:

没有答案