+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / UpdatePanel and Response.Redirect

UpdatePanel and Response.Redirect

20 posts, 0 answered
  1. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    20 Oct 2011
    Link to this post

    Hello,
    I'm facing a problem with this:

    Most of my Response.Redirect calls inside standard  <asp:UpdatePanel>
    resolve unrecognizable URLs in Sitefinity.

    ie:
    Response.Redirect("~/MyAccount")
    Result in:
    http://localhost/MySitefinityWebApp/%2fMySitefinityWebApp%2fMyAccount

    This is how my HTML Looks like:

    <asp:UpdatePanel ID="udpErrorMessages" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
            <ContentTemplate>
                <!-- ANY CONTENT HERE -->
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnValidate" />
            </Triggers>
    </asp:UpdatePanel>

    The btnValidate executes the Response.Redirect.
    If I Quick-watch the ResolveUrl("~/MyAccount") just before the execution I looks normal but the Response.Redirect("~/MyAccount") mess things up.

    PS: I'm not using telerik controls and in a Asp.Net App outside Sitefinity this is not an issue.

    Any help will be appreciated.
  2. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    21 Oct 2011
    Link to this post
    Might be completely wrong, but I remember using something like
    Response.Redirect(Server.MapPath("~/whatever"));
    just a passing thought. as i said i might be wrong.

  3. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    21 Oct 2011
    Link to this post

    Thanks Andrei ,

    Same issue the URL now looks more scrambled.

    Looks more like an internal problem in the Redirect no matter what I send a hard-coded url:
    Response.Redirect("~/MyAccount")

    The address bar in the browser shows:
    http://localhost/MySitefinityWebApp/%2fMySitefinityWebApp%2fMyAccount

    Again only in code behind executed from a <asp:UpdatePanel>

    I read a post that suggest using RadAJaxManager.Redirect instead of regular ASP Response.Redirect.
    But that force me to change all regular panels and managers to Rad controls.

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/response-redirect-url-problem.aspx

  4. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    21 Oct 2011
    Link to this post
    have you seen this: http://forums.asp.net/t/1640586.aspx/1

    I use buttons extensively in my Sitefinity project, but i assign the PostBackUrl (this.aspButton.PostBackUrl = "";) and work that way. Below is a code example of how I use it, which might not help at all.
    public partial class AspButton : System.Web.UI.UserControl
    {
        private FluentSitefinity fluent = App.WorkWith();
        
               // You would need to get the Guid of the page in question somehow.
        private Guid _selectedPage;
        public Guid SelectedPage
        {
            get
            {
                if (this._selectedPage == null)
                    return Guid.Empty;
                return this._selectedPage;
            }
            set { this._selectedPage = value; }
        }
     
        public string SelectedPageTitle
        {
            get
            {
                if (this.SelectedPage == null || this.SelectedPage == Guid.Empty)
                    return String.Empty;
                return fluent.Page(this.SelectedPage).Get().Title;
            }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            //load the post back url
            if (this.SelectedPage != Guid.Empty)
            {
                try
                { this.aspButton.PostBackUrl = fluent.Page(this.SelectedPage).Get().GetFullUrl(); }
                catch
                { this.aspButton.PostBackUrl = ""; }
            }
        }
    }

  5. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    21 Oct 2011
    Link to this post

    Not a solution but thanks a lot..

    I'm creating a support ticket instead.  Is very simple and easy to replicate. I don't think I'm doing something wrong but in standard ASP Net the issue is not present.

    I was trying to attach the entire sitefinity project so anyone could replicate the issue..but due to  the 2 mb limit is impossible.

    Thanks again.

  6. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    24 Oct 2011
    Link to this post
    Ok sorry Ronny. I know thet in the past I had to be careful about defining Page.IsPostback() or this.IsPostback(). Telerik are quite helpful when it comes to tickets, so good luck.
  7. Mark
    Mark avatar
    22 posts
    Registered:
    16 Sep 2012
    29 Nov 2011
    Link to this post
    Telerik,

    I'm having the same problem with Response.Redirect and I'm also in an asp:UpdatePanel.  This code works just fine in a standard aspx page, but doesn't work from within Sitefinity.  I've tried the following in my code-behind:

    Response.Redirect(~/thankyou, true);
    Response.Redirect(/thankyou, true);

    In either case the rendered url is http://testserver.com/account/%2fThankYou.  My first question is why isn't the url rendered as root relative?  I've tried encoding the url in the code-behind as well which has no effect.

    Our shop is running Sitefinity 4.2.1650

    Thank you.

    Mark
  8. Tim
    Tim avatar
    258 posts
    Registered:
    22 Jun 2011
    29 Nov 2011
    Link to this post
    Mark,

    I did some searching and it seems you're not alone. Adding the following section to your web.config may solve your issue.

    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>

    Hope it helps!
  9. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    29 Nov 2011
    Link to this post
    Hello Tim,

    Thanks for the interest .. Yes, Actually the solutions came from Sitefinity team...and works perfectly for 4.2..

    I'm pasting it. this can be helpful to anyone running the same issue..

    <"Hi Ronny,

     The problem is that Sitefinity uses outdated scripts in some cases. If you need to call the Response.Redirect in your update panel you will have to make a small change in your configuration. Navigate to Administration -> Settings -> Advanced. In the left panel navigate to the following nodes Pages -> Script Manager -> Script References -> MicrosoftAjaxWebForms. Look at the main area. Change the Name field from "Telerik.Sitefinity.Resources.Scripts.MicrosoftAjaxWebForms.js" to "MicrosoftAjaxWebForms.js" and theAssembly field from "Telerik.Sitefinity.Resources" to "System.Web.Extensions" and press the "Save changes" button. You can also look at the attached image.
    http://www.sitefinity.com/ClientsFiles/246191_settings.jpg
    After this change, you will be able to use your redirects inside the UpdatePanel.

    Greetings,
    Svetoslav Petsov
    the Telerik team">
  10. Mark
    Mark avatar
    22 posts
    Registered:
    16 Sep 2012
    29 Nov 2011
    Link to this post
    Thanks.  That fixed the issue.

    Mark
  11. SteveV
    SteveV avatar
    178 posts
    Registered:
    06 Nov 2011
    16 Dec 2011
    Link to this post
    Just got bit by this one and it ended up costing me a couple of hours before I stumbled on this post.  Thanks for posting the fix.

    --Steve
  12. Adam
    Adam avatar
    16 posts
    Registered:
    29 Nov 2011
    07 Feb 2012
    Link to this post
    Thanks for posting this!

    This issue is still alive and well in SF 4.3, but only when logged in as an administrator. When using the site anonymously or as a basic user, everything worked fine. Once logged in as an admin, all the urls got corrupted as described above. The above solution fixed the issue.
  13. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    07 Feb 2012
    Link to this post

    Sure, you're welcome,
    Great to know the solution is still valid..
    (the attached image is no longer available but hope instructions are clear).
    Actually we are in 4.4 now and as a rule we change the script reference resources from telerik's to microsoft's.

  14. Priya Ramesh
    Priya Ramesh avatar
    26 posts
    Registered:
    23 Jul 2009
    16 May 2012
    Link to this post
    I am using sitefinity 3.7 and have the same issue. Does the same fix work for 3.7
    Thanks,
    Priya
  15. Priya Ramesh
    Priya Ramesh avatar
    26 posts
    Registered:
    23 Jul 2009
    17 May 2012
    Link to this post
    I am using sitefinity 3.7 and have the same issue. Does the same fix work for 3.7
    Thanks,
    Priya
  16. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    17 May 2012
    Link to this post

    I’m not familiar with 3.7 but if you are able to change the reference from telerik’s to Microsoft’s by backend settings, give it a shot.

    Good luck.
  17. James
    James avatar
    1 posts
    Registered:
    18 May 2012
    18 May 2012
    Link to this post
    it works for me, thanks.
  18. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    31 Jul 2012
    Link to this post
    Hi I had same issue and was breaking my head, I had a custom login control and was trying to implement secure pages on multi site solution, Once user clicked to secure page, it was being redirected to login page, though from their it was always trying to redirect to eg> 

    Click on "Contact Us" (a secure page)
    The link is: http://mytestsite.com/1/login?ReturnUrl=/1/contact-us
    Login and
    Site breaks as it goes to http://mytestsite.com/1/%2f1%2fcontact-us

    This solution worked for me:

    The problem is that Sitefinity uses outdated scripts in some cases. If you need to call the Response.Redirect in your update panel you will have to make a small change in your configuration. Navigate to Administration -> Settings -> Advanced. In the left panel navigate to the following nodes Pages -> Script Manager -> Script References -> MicrosoftAjaxWebForms. Look at the main area. Change the Name field from "Telerik.Sitefinity.Resources.Scripts.MicrosoftAjaxWebForms.js" to "MicrosoftAjaxWebForms.js" and theAssembly field from "Telerik.Sitefinity.Resources" to "System.Web.Extensions" and press the "Save changes" button. You can also look at the attached image.
    http://www.sitefinity.com/ClientsFiles/246191_settings.jpg
    After this change, you will be able to use your redirects inside the UpdatePanel.
  19. Rabeya
    Rabeya avatar
    1 posts
    Registered:
    01 Aug 2012
    01 Aug 2012
    Link to this post
    I am experiencing similar issues response.redirect not working inside an update panel.  Changing the web.config file didnt work in my end.  I am using vs2010 and can't find Administration menu.  Please help !!!
  20. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    01 Aug 2012
    Link to this post

    Hi,
    You need to login into the Sitefinity backend and change the setting in the advanced configuration setting.
    Actually you don't need to change anything in the web.config.. See this sample:
    http://www.sitefinity.com/ClientsFiles/246191_settings.jpg 

    Follow this instructions to get there:
    " The problem is that Sitefinity uses outdated scripts in some cases. If you need to call the Response.Redirect in your update panel you will have to make a small change in your configuration. Navigate to Administration -> Settings -> Advanced. In the left panel navigate to the following nodes Pages -> Script Manager -> Script References -> MicrosoftAjaxWebForms. Look at the main area. Change the Name field from "Telerik.Sitefinity.Resources.Scripts.MicrosoftAjaxWebForms.js" to "MicrosoftAjaxWebForms.js" and theAssembly field from "Telerik.Sitefinity.Resources" to "System.Web.Extensions" and press the "Save changes" button. You can also look at the attached image.

    http://www.sitefinity.com/ClientsFiles/246191_settings.jpg
    After this change, you will be able to use your redirects inside the UpdatePanel.

    Greetings,
    Svetoslav Petsov 
    the Telerik team" 

    Hope this helps.
20 posts, 0 answered