Fix: ASP.NET 4 Page on IIS 7 Misbehaves When Browser URL Doesn’t Include Default Page
After deploying an ASP.NET 4 application to the production server, data submitted in a form on the default page went nowhere. I discovered that the page worked normally if I included the name of the default document as in http://mydomain.com/default.aspx. When I navigated to the site as http://mydomain.com the postback misbehaved to the extent that there was no SQL connection – as if it didn’t even try.
All this worked fine on the development server which is IIS 6. The production server is IIS 7.
The fix was to go into my site’s master page and set the action attribute to default.aspx in the form tag:
<form id="form1" action="default.aspx" runat="server">
There’s a detailed explanation in the section “Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode” of the ASP.NET 4 Breaking Changes document.
Am I the only one who loses time on stuff like this?
Ken