9

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

Keith K
  • 2,893
  • 4
  • 33
  • 43
  • 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 Answers3

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
  • Can't do it from the master? Urgh. –  Oct 06 '08 at 16:11
  • Sadly, it does not appear so. – Mitchel Sellers Oct 06 '08 at 16:24
  • 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
  • Yeah, Response would be the only from from the master page. – Tom Oct 06 '08 at 17:40
  • 3
    Classic 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
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