Button click handler not being called unless form action is specified
I have a simple ASP.NET web application for data collecting (a webform with two text fields and a Telerik editor, a button for submit with server side OnClick event listener attached). The event listener saves data on DB and then redirects to another page. Under development web server the application works fine. When published under IIS7 the event listener doesn't fire. The only way i found to make it work is to specify the action on the form tag:
<form id="form1" action="default.aspx"开发者_运维技巧 runat="server">
This is the first time this happens to me, i never run into this problem before with other applications (even more complex!).
Did anyone seen this behaviour before? Any (smarter) solutions other than mine?
Thanks.
If you check the source of the generate html, it will contain the action for the form tag regardless of whether you specify it or not. So can you check what is the action in the resultant html when you don't put action="default.aspx" explicitly.
I have seen similar behaviour when i had implemented some url rewriting, then the generated form action was becoming wrong. I had to set the action in the code behind to
Page.Form.Action = ResolveUrl(string.Format("~/{0}", Path.GetFileName(Request.CurrentExecutionFilePath)));
Also can you check that the same behavior is there in both Integrate Pipeline, and classic mode of IIS7.
精彩评论