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
Asked
Active
Viewed 1.9k times
9
-
BTW, after doing this, just about every browser took a dump on me. So I left it the way it was being sent. Web standards, you gotta hate 'em. – Oct 08 '08 at 14:17
3 Answers
15
You can specify it in the @ page attributes section, like this:
<%@ Page ContentType="application/xhtml+xm" %>
...more on MSDN.

T.J. Crowder
- 1,031,962
- 187
- 1,923
- 1,875

Mitchel Sellers
- 62,228
- 14
- 110
- 173
-
-
-
I guess you could set it via Response but that might get a bet sketchy in terms of functionality – Mitchel Sellers Oct 06 '08 at 16:25
-
-
3Classic example of [why link-only answers are a bad idea](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers). The answer didn't actually answer the question unless you followed the link. The link died, making the answer completely useless. I've fixed it -- by fixing the link (for now), but more importantly by actually putting the answer **in** the answer. – T.J. Crowder Dec 27 '12 at 12:56
4
In your code behind file, during the Page_Load event, try addind the following code:
Response.Clear()
Response.ContentType = "application/xhtml+xm"

Dillie-O
- 29,277
- 14
- 101
- 140
-
That's the property you want, but you'll probably want to set it sooner than load (maybe Pre_Init) – John Sheehan Oct 06 '08 at 16:08
0
=========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\">";
}

apros
- 2,848
- 3
- 27
- 31
-
Your code is not related to the question, but it helped me- see http://geekswithblogs.net/mnf/archive/2011/09/23/change-doctype-dynamically.aspx – Michael Freidgeim Sep 24 '11 at 02:39