My younger brother was forced to use Ajax recently, so he used asp.net ajax to implement it. Well, that's simple. It's done in three or two times... but the problem also immediately came out. It conflicted with my url rewriting. My url rewriting module was written by myself, A filter has long been used to solve the problem of incorrect submission location of the server form, but now, as long as it is 2nd times to use ajax for sending back, the 404 error will be reported, when someone came to cnblogs to see this problem, they said they could solve the problem by modifying the action. I was wondering that the action had been solved for a long time and it seems to be the best solution... so I opened a hook program, grabbed the final post address of ie each time, and found that after 2nd ajax replies, it will be his submission location (not the page action, but a form generated by js in aspnet ajax. _ initialAction) address is changed to relative path, of course there will be problems, so please find the brother of url rewriting conflicts with ajax, pay attention to test this problem, don't let things get online to discover problems... not to mention I think it's all right if I modify the action... in fact, I think it's a defect of "ASP. net ajax RC1". Why should I use a relative path? Honestly, it is better not to take actions so many strange operations? Of course, I don't know his design principles. I guess he has his own reasons. The code for solving this problem is as follows:
<! -- Ajax script manager -->
<Asp: ScriptManager ID = "ScriptManager1" runat = "server"> </asp: ScriptManager>
<Script type = "text/javascript">
Sys. Application. add_load (function ()
{
Var form = Sys. WebForms. PageRequestManager. getInstance (). _ form;
Var href = window. location. href;
If (href. indexOf ("? ")> 0)
{
Href + = "& a =" + Math. random ();
}
Else
{
Href + = "? A = "+ Math. random ();
}
Form. _ initialAction = href;
Form. action = href;
});
</Script>
You may have noticed that this Code adds a random number to the address to solve the following problem (browser cache conflict), but it does not solve it well...
OK. The rewrite conflict is fixed, and 2nd problems occur again... After speculation, I think it is a browser cache problem. I have implemented a tags addition and deletion function, so I don't need to say much about it. Deleting is to put an ImageButton In the Repeater, the current tag is uploaded back to and deleted using the CommandName In the click event. This problem occurs. When I add multiple tags, click Delete, the tags list in updatepanel returns the status before adding 1st, so I suspect it is a browser cache problem, and I am also stupid to add it to the server code
Response. Cache. SetNoStore ();
Response. Cache. SetLastModified (DateTime. Now );
I hope the problem can be solved, but in fact it is useless. _ initialAction adds a random number to the end of the url. The result is still invalid... I guess the problem is that this random number does not work every time, but I really don't have time to fully understand the principles of asp.net ajax, so I want to know how to solve this problem first.