Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode?
Asked Answered
F

1

12

After pulling my hair out for the last three days in my first non-upgraded ASP.NET 4.0 Web Application, I stumble across this post explaining it all.

http://jai-on-asp.blogspot.com/2010/06/changes-and-differences-between-aspnet.html under the section labeled: Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode

Apparently, an asp.net page at this address: http://www.mydomain.com/ will not post back to itself without explicitly adding action="default.aspx" in the <form> tag.

Well, what happens when you are using a Master Page (where the <form> tag is location when using Master Pages)?

How do I get my default.aspx pages to postback to themselves in .NET 4.0 using Master Pages?

Friede answered 12/1, 2011 at 19:45 Comment(0)
C
10

Whether the form is specified on the default page, or in the master page, it is still accessible via the Form property on the page.

Therefore, you should be able to set it's action in the code behind for that page.

protected void Page_Load(object sender, System.EventArgs e)
{
    this.Form.Action = "Default.aspx";
}
Cirque answered 26/3, 2011 at 12:34 Comment(1)
True, and that was more of a brain-fart on the masterpage side-note issue. The bigger issue is just the inconsistency that I have to remember every time I'm using a default page that I have explicitly set the action which I don't have to for any other page. I don't get it. Why the change?Friede

© 2022 - 2024 — McMap. All rights reserved.