Search code examples
asp.netajaxurl-rewritingupdatepanelviewstate

Custom UrlRewriting leads to AjaxControlToolkit UpdatePanels wrong request url on second postback


I'm trying to implement custom urlrewriting in the global.asax of my website and i'm experiencing some troubles with updatepanels from the ajaxcontroltoolkit:

  • second post back of my updatepanels seems to request the wrong url (ie : if my rewrited url is /en-US/parentPage/myPage.html and the physical url is /default.asp?ln=en-US&page=myPage, the second post back request /en-US/parentPage/default.asp?ln=en-US&page=myPage, which leads to file not found ...)

I dont know if it matter but i desactivated the viewstate on the page by setting Page.EnabledViewState to false.

To implement urlrewriting i used Server.Transfert(physicalUrl, true)

Also i tried to set the form action to my rewritted url to solve the problem but then none of the postback are working anymore even those from controls not in an updatepanel.

How can i solve my updatepanels problem ? Is it possible to do it with form action set to rewritted url ?

Thanks a lot ;)


Solution

  • i find a solution to my problem, it seems the problem came from the viewstate of the page not being reloaded correctly due to the server.transfert so i implemented a custom viewstate save/load functin as follow and then everything worrked perfectly ;) :

        protected override object LoadPageStateFromPersistenceMedium()
        {
            object viewstate = Session["__VIEWSTATE"];
            return viewstate;
        }
        protected override void SavePageStateToPersistenceMedium(object state)
        {
            Session["__VIEWSTATE"] = state;
        }