UpdatePanel and Response.Redirect

Posted by Community Admin on 03-Aug-2018 19:28

UpdatePanel and Response.Redirect

All Replies

Posted by Community Admin on 20-Oct-2011 00:00


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:
localhost/...//MySitefinityWebApp/MyAccount

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.

Posted by Community Admin on 21-Oct-2011 00:00

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.

Posted by Community Admin on 21-Oct-2011 00:00


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:
localhost/...//MySitefinityWebApp/MyAccount

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.

www.sitefinity.com/.../response-redirect-url-problem.aspx

Posted by Community Admin on 21-Oct-2011 00:00

have you seen this: forums.asp.net/.../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 = "";
        
    

Posted by Community Admin on 21-Oct-2011 00:00


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.

Posted by Community Admin on 24-Oct-2011 00:00

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.

Posted by Community Admin on 29-Nov-2011 00:00

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

Posted by Community Admin on 29-Nov-2011 00:00

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!

Posted by Community Admin on 29-Nov-2011 00:00

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">

Posted by Community Admin on 29-Nov-2011 00:00

Thanks.  That fixed the issue.

Mark

Posted by Community Admin on 16-Dec-2011 00:00

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

Posted by Community Admin on 07-Feb-2012 00:00

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.

Posted by Community Admin on 07-Feb-2012 00:00


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.

Posted by Community Admin on 16-May-2012 00:00

I am using sitefinity 3.7 and have the same issue. Does the same fix work for 3.7
Thanks,
Priya

Posted by Community Admin on 17-May-2012 00:00

I am using sitefinity 3.7 and have the same issue. Does the same fix work for 3.7
Thanks,
Priya

Posted by Community Admin on 17-May-2012 00:00


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.

Posted by Community Admin on 18-May-2012 00:00

it works for me, thanks.

Posted by Community Admin on 31-Jul-2012 00:00

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: mytestsite.com/.../login
Login and
Site breaks as it goes to mytestsite.com/...//1/contact-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.

Posted by Community Admin on 01-Aug-2012 00:00

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 !!!

Posted by Community Admin on 01-Aug-2012 00:00


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.

This thread is closed