The W3C has introduced a MIME type for XHTML documents. This new MIME type is application/xhtml+xml. The W3C recommends that you use the application/xhtml+xml MIME type when serving XHTML documents, because XHTML pages should be interpreted in a stricter way than legacy HTML pages.
You can serve an ASP.NET page with a particular MIME type by including the ContentType attribute in a page directive. For example, including the following directive at the top of an ASP.NET page causes the page to be served as application/xhtml+xml.
<%@ ContentType="application/xhtml+xml" %>
Doing so will force you to make sure your web pages are valid XHTML files because they’ll break if your code is sloppy.
Ok, that’s great… except for the fact that Internet Explorer will now display your web site as an XML file instead of an HTML file! There are a few work-arounds for this, but the easiest one for ASP.NET 2.0 sites seems to be this simple addition to the Global.asax file:
<script runat="server">
Sub Application_PreSendRequestHeaders(ByVal s As Object, _
ByVal e As EventArgs)
If Array.IndexOf(Request.AcceptTypes, _
"application/xhtml+xml") > -1 Then
Response.ContentType = "application/xhtml+xml"
End If
End Sub
</script>