Response.Redirect doesn't work with UpdatePanel in Beta 1

Last post 01-05-2008 4:54 AM by Gayathri_Bangalore. 17 replies.

Sort Posts:

  • Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 3:41 PM
    • Loading...
    • TheKyle27
    • Joined on 10-24-2006, 7:07 PM
    • Posts 5

    I have a page with an update panel that contains a few buttons that need to be able to redirect to another page.  The script manager is located on a master page.

    Every time one of those buttons are clicked, i get one of two errors:

    1. If the button is inside of a gridview, i get this error:
      Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
    2. If the button is NOT inside of a gridview, i get this error:
      Sys.WebForms.PageRequestManagerParserErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 302

     Here's a test aspx page that I set up: 

    1    <%@ Page Language="VB" title="Untitled Page" MasterPageFile="~/main.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
    2    <%@ Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>
    3    <asp:Content ID="Content1" ContentPlaceHolderID="plhContent" Runat="Server">
    4        <ajax:UpdatePanel runat="server">
    5            <ContentTemplate>
    6                <asp:Label runat="server" ID="lblTime" /><br />
    7                <asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />
    8                <asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />
    9                <asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />
    10               <a href="http://www.google.com/" title="test redirect">HTML Hyperlink</a>
    11           </ContentTemplate>
    12       </ajax:UpdatePanel>
    13   </asp:Content>
    
     And here's the codebehind: 
    1    Partial Class test
    2        Inherits System.Web.UI.Page
    3    
    4        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    5            lbltime.Text = now()
    6        End Sub
    7    
    8        Protected Sub btnRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRedirect.Click
    9            Response.Redirect("http://www.google.com/", True)
    10       End Sub
    11   
    12       Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
    13           lblTime.Text = Now()
    14       End Sub
    15   
    16       Protected Sub lnkRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRedirect.Click
    17           Response.Redirect("http://www.google.com/", True)
    18       End Sub
    19   End Class
    

     
    The LinkButton causes the same error, so it's not just limited to the button control.  It looks like it affect anything that posts back to the server and causes a redirect. 

    Thanks for any help you can give me!

     

  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:07 PM
    • Loading...
    • suprduprmn
    • Joined on 06-27-2006, 3:35 PM
    • Sandpoint, ID
    • Posts 36

    We found this out today too.  The fix is to pass a location.href back to user.

      

    ScriptManager.RegisterStartupScript(pnlYourUpdatePanel, this.GetType(), "redirectMe", "location.href='blah.aspx';", true);
     

    Sorry it is in C#... Hope this helps. 

    0100110101000001010101000101010001011001
    matthew r. williams | internet developer />
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:29 PM
    Answer
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello.

    i've just built a sample project with the following code:

    master page:

    <%@ Master Language="VB" %>

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

    <script runat="server">

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:scriptmanager runat="server" ID="manager" />
            <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
            </asp:contentplaceholder>
        </div>
        </form>
    </body>
    </html>

    page:

    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
    <script runat="Server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            lblTime.Text = Now()
        End Sub
       
        Protected Sub btnRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRedirect.Click
            Response.Redirect("http://www.google.com/", True)
        End Sub

        Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
            lblTime.Text = Now()
        End Sub

        Protected Sub lnkRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRedirect.Click
            Response.Redirect("http://www.google.com/", True)
        End Sub
    </script>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <asp:updatePanel runat="server" id="panel">
            <contenttemplate>
                <asp:Label runat="server" ID="lblTime" /><br />
                    <asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />
                    <asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />
                    <asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />
                   <a href="http://www.google.com/" title="test redirect">HTML Hyperlink</a>
            </contenttemplate>
        </asp:updatePanel>
    </asp:Content>

     everything is working here with the beta extensions. are you sure you've set up web.config correctly?

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:40 PM
    • Loading...
    • suprduprmn
    • Joined on 06-27-2006, 3:35 PM
    • Sandpoint, ID
    • Posts 36

    Luis,

     When looking at the XMLHttpResponse google.com is being returned which is causing the parser error.  Not sure how you are getting this to work with the Beta release??  Also, not sure how config would cause this?

     Matt

     

    0100110101000001010101000101010001011001
    matthew r. williams | internet developer />
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:45 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello.

    well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just  blow everything apart. btw, here's what i'm getting back from the server side in response to a click over the redirect button (2nd one from the top):

     
    22|pageRedirect||http://www.google.com/| 

     

     

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:45 PM
    • Loading...
    • TheKyle27
    • Joined on 10-24-2006, 7:07 PM
    • Posts 5
    Luis Abreu:

     everything is working here with the beta extensions. are you sure you've set up web.config correctly?

    I think I do.  I have a Microsoft.Web.Extensions assembly in the web.config.  Is there aything else I need? 

     
    1    <compilation debug="true" strict="false" explicit="true">
    2        <assemblies>
    3            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    4            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    5            <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    6        </assemblies>
    7    </compilation>
    

     

     

  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:49 PM
    • Loading...
    • TheKyle27
    • Joined on 10-24-2006, 7:07 PM
    • Posts 5
    Luis Abreu:

    well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just  blow everything apart.

    I did delete the old CTP DLL, and added the new assembly registration to the top of the page: 

    1    <%@ Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>
    2    
    
     
     
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:54 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello again.

    can you confirm the response you're getting back from the server? is it similar to the one i've shown before? 

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 5:56 PM
    • Loading...
    • TheKyle27
    • Joined on 10-24-2006, 7:07 PM
    • Posts 5
    How do I access the server response information?
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 6:09 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218
    • TrustedFriends-MVPs

    hello.

    use fiddler. if you're using ie, you must create a site in IIS and then use the name of the machine (http://machinename/site). if you're using firefox, configure it so that it uses a local proxy (127.0.0.1 port 8888 if i'm not mistaken).

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 6:09 PM
    Answer
    • Loading...
    • suprduprmn
    • Joined on 06-27-2006, 3:35 PM
    • Sandpoint, ID
    • Posts 36

    It is definitely in the config.  Again... good call Luis... you are missing these values in your config and this should cure the problem.

      

    		<httpModules>
    			<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    			<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    		</httpModules>
     Thank Luis for that one.  =)
    0100110101000001010101000101010001011001
    matthew r. williams | internet developer />
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 6:10 PM
    Answer
    • Loading...
    • suprduprmn
    • Joined on 06-27-2006, 3:35 PM
    • Sandpoint, ID
    • Posts 36
    P.S. That is under httpHandlers
    0100110101000001010101000101010001011001
    matthew r. williams | internet developer />
  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    10-24-2006, 6:17 PM
    • Loading...
    • TheKyle27
    • Joined on 10-24-2006, 7:07 PM
    • Posts 5

    That worked!  You guys are awesome.

     
    Thanks!

  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    11-09-2006, 1:29 PM
    • Loading...
    • Neteva
    • Joined on 11-02-2006, 7:16 PM
    • Posts 1

    Thanks - Guys! 

     I was experiencing the same problem in Beta 2, which this solution apparently resolved that issue.

  • Re: Response.Redirect doesn't work with UpdatePanel in Beta 1

    12-21-2006, 9:02 AM