在 IIS 7 或 IIS 7.5 集成模式下的默认文档中可能不会引发事件处理程序?
在我的第一个未升级的 ASP.NET 4.0 Web 应用程序的最后三天里,我无意中发现了这篇解释这一切的帖子.
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 在标记为:Event Handlers Might Not Raised in a Default Document in IIS 7 或IIS 7.5 集成模式
显然,这个地址是一个 asp.net 页面:http://www.mydomain.com/如果没有在 <form
> 标签中明确添加 action="default.aspx",将不会回传给自身.
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.
那么,当您使用母版页时会发生什么(使用母版页时 <form
> 标签是位置)?
Well, what happens when you are using a Master Page (where the <form
> tag is location when using Master Pages)?
如何使用母版页让我的 default.aspx 页面在 .NET 4.0 中回发到自己?
How do I get my default.aspx pages to postback to themselves in .NET 4.0 using Master Pages?
无论是在默认页面,还是在母版页面中指定表单,它仍然是可通过页面上的表单属性访问.
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";
}