Create a brand new asp.net webforms project. Add a master page and a webforms page that uses that master page.
master page
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="AspWeird.Site1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="main_content_container">
<div id="main_content_row">
<div id="main_content_column">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="side_content_column">
</div>
</div>
</div>
</div>
</form>
</body>
</html>
webforms page
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AspWeird.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>Hello World</h2>
<div>
<form></form>
</div>
</asp:Content>
Now view the page in IE9 and open the F12 Developer tools
If you look you will see that part of the master page looks like it is in the DOM twice...examining the network capture the server looks to be returning the correct HTML. Do not have any problems with firefox or chrome.
screenshot http://dl.dropbox.com/u/1994980/IE9_duplicate_content.PNG
This开发者_开发百科 only happens with the
<div><form></form></div>
block in there. If you remove it everything is normal.
Whole project zipped up
Nested form tags makes for invalid HTML and the rendering you see in IE9 is very likely a result of that. The DOM you see in developer tools is what is rendered not what is received as a HTTP response
In general, ASP.NET works based on a single form tag. That you see the symptoms you do and not an outright error is really the only surprising part. Thus, you should not try to nest form tags. From the lowest master to the outer most derived page should only have a single form tag.
Update
This definitely looks like a bug in IE9. If you use Fiddler to view the actual markup being sent across the wire, the code is not duplicated.
精彩评论