问题
I'm specifying my doctype as xhtml strict, but it's being sent over the wire as a content type of text/html. I'd like to specify that the content type is application/xhtml+xm, but I can't figure out where, or if, I can configure this from within my application
回答1:
You can specify it in the @ page attributes section, like this:
<%@ Page ContentType="application/xhtml+xm" %>
...more on MSDN.
回答2:
In your code behind file, during the Page_Load event, try addind the following code:
Response.Clear()
Response.ContentType = "application/xhtml+xm"
回答3:
=========aspx===============
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<asp:literal runat="server" id="dt"></asp:literal>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
==============code behind=========
protected void Page_Load(object sender, EventArgs e)
{
this.dt.Text= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
}
来源:https://stackoverflow.com/questions/174916/how-do-you-specify-your-content-type-in-asp-net-webforms