I am having two related issues with ASP.NET AJAX. I used the AtlasToolkit PopupControlExtender to create a very simple Popup Calendar. I have created a custom HtmlTextWriter and HttpModule to rewrite incoming url's based on incoming path. So essiently if I nav /This/Page/Does/Not/Exist.aspx, the module will check the file system to see if that page physically exists, and if not then check the database for the corresponding PageId and rewrite it ~/Page.aspx?PageId=DoesNotExistId. Then I have overriden Render and written a custom HtmlTextWriter that looks for <form action=""> and sets that attribute equal to the fully qualified url requested.
The problem goes like this. Anytime before I do any ASP.NET UI events, everything is fine. After an ASP.NET AJAX UI event the Form.Action attribute reads Page.aspx?pageid=blah. Is there anyway to override this behavior?
Thank you,
Jason Lind
I'm like 99% sure this a bug. The line of js that causes this most of the time will do nothing, except when you're rewriting and then it breaks your application
See lines 1061 through 1069 in MicrosoftAjaxWebForms.js (the debug version) pasted here for your convienance:
if (handler) { handler(this,this._getPageLoadingEventArgs()); }if (formActionNode) {this._form.action = formActionNode.content;this._form._initialAction =this._form.action; }Basically on any ASP.NET AJAX ui event the form.action is being reset to the response. I can see no reason for doing this, for as far as I can tell there is no information being added to the action. My guess is at some version in development this was the case and that approach was later dropped and this code never was refactored.
Can someone on the ASP.NET AJAX team please confirm this and assure me that in some later release this won't be an issue, maybe even commentif (formActionNode) {this._form.action = formActionNode.content;this._form._initialAction =this._form.action; } out and issue me a hot fix?
Thank you,
Jason Lind
Lead Software Engineer / Triton Tek
<script type="text/javascript">
Type.registerNamespace("ScriptLibrary");
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageLoaded);
function pageLoaded(sender, args) {
document.forms[0].action = requestUrl;
document.forms[0]._initialAction = requestUrl;
}
var requestUrl = "";
function body_onload()
{
requestUrl = document.forms[0].action;
}
</script>
Still should be fixed.
Kinda hard to say what's going on here, but first here's why we do that form action stuff. When modules such as session and authentication rewrite the URL in their cookieless modes, we need to reset the form action to be whatever the rewritten URL is. We do it in a manner similar to what you're doing by checking the form's action and grabbing whatever it has.
However, in your case it sounds like you're using a customwriter to do the work, which might be the problem in this scenario. Instead you should override the form's rendering functionality and just change the action there. Then Atlas will pick it up and use whatever you set. Here are a couple of articles on the subject:
General URL rewriting:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp (but, ignore the part where it says to write an actionless URL!)
Atlas URL rewriting:http://geekswithblogs.net/lazydeveloper/archive/2006/08/17/88247.aspx (this is the important part)
Thanks,
Eilon
No comments:
Post a Comment