Im trying to implement ajax on the site im working on. Everything works perfectly well the first time im doing a partial postback. However the second time, it doesnt work and i get some client-script 404 error. The reason is unknown, the only thing i know is that it is probably related to episervers urlrewrite-module, because it works if im on Site/default.aspx. but it doesnt work if im on any urlrewrited-page.
The problem is probably related to this thread:
http://www.episerver.com/en/EPiServer_Knowledge_Center/Developer-Forum2/EPiServer-Developer-Forums-/1805/10539/
But the code provided on that thread doesnt seem to work, at least not on Episerver CMS 5.
Any help is appreciated, i have no idea how to solve this.
And im also losing the title everytime im doing a partial postback...for some reason
Thank you!
The ASP.NET 2.0 script callback functionality has a known problem in that it by default sets MIME type text/html - which is patently wrong - for the response. This in turn triggers UrlRewriting which get's mightily confused by the syntax used in the response, which is simply not HTML.
EPiServer, which uses script callbacks, solves this problem by setting the MIME type of script callback responses to text/plain, which is much closer to the truth.
Please let us know if this solves your problem, otherwise let us know more about the problem.
Ok thanks so far...
I have tried to track down the problem a little more with a client script debugger:
The first time iam doing a partial postback. The requested url is /SiteName/en/Hello/ <-Which is correct, because it is the urlrewrited page of the page Hello.aspx(for example).
However the second time im doing a partial postback on the same page, the requested url is /SiteName/en/Hello/Hello.aspx <-which is incorrect because Hello.aspx doesnt exist under the folder en/Hello/. So basically that IS the problem. But i still have no idea how to solve it... So some help is appreciated.
And the reason the Title is lost is probably because it tries to reach the title information from a page that doesnt exist.
Any help is appreciated,
Fredrik
Ahh, nice i solved it.
http://www.worldofasp.net/AJAX/re-2235_Tip-Trick--Url-Rewriting-with-ASP-NET.aspx
I downloaded and implemented the form control adapter which can be found in that article. And it all started working!
The Title problem was related to having a literal in the head section in my masterpage. I deleted the literal and called a function like ]]> instead.. and it all worked!
There's a slight problem here. The UrlRewrite module should handle all rewrites of the forms action attribute, which apparently is what the Form Control Adapter referenced fixes. The need to change the response MIME type only exists when it's a script callback - and the content of that response will not be rewritten by UrlRewrite.
So, if you need the form control adapter, something else is actually amiss here. Either it's a bug in the UrlRewrite module, or there's something with your code causing it not to work.
The EPiServer CMS UrlRewrite is not a trivial rewrite of incoming URL's - it's a full reverse proxy, rewriting all URL's in the outgoing response HTML as well - including action attributes of the form element. It already does what the adaptor does - and much more so.
Could you please enable logging at the debug-level, and send the log to me I'd appreciate it. We want to know why you're not getting a correct rewrite.
In your application root you should have a file named EPiServerLog.Config.Template. Rename this to EPiServerLog.Config (or merge with the existing, letting the existing win if it's already there). Open in Notepad. Go to the end of the file and change level value to "Debug", and uncomment the "appender-ref ref="fileLogAppender"" entry. You should now get a file named EPiServerErrorLog.txt in your application root - provided the account IIS executes under has modify rights there.
Hmmm... The reason is probably because we've made a mistake. It's good that this was noted, will be fixed. Anyway, place the following in EPiServerLog.Config, and you'll get a log file in the user that IIS is running under's temp-folder:
Hi.
I just want to add that there is a faq about loggin in EPiServer:
http://www.episerver.com/en/EPiServer_Knowledge_Center/FAQ_EPiServer_4/1053/6486/
and technote:
http://www.episerver.com/en/EPiServer_Knowledge_Center/Documentation/TechNotes/Logging-in-EPiServer/
-- Per