I am attempting to set the content-type of an asp.net .ashx
file to text/plain
.
When I run this through the ASP.NET Development Server, the content-type is properly set. When I serve it through IIS7, however, the content-type (and any other header values I set) don't come through (it came through as text/html
).
The only value set in the HTTP Response Headers section of IIS Manager is the X-Powered-By
attribute. I tried setting the content-type here, but that didn't work. But if I removed the X-Powered-By
attribute, it was removed from the header.
Any ideas?
Code in .ashx file
public class Queries1 : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("hello");
}
public bool IsReusable
{
get { return false; }
}
}
HTTP Header from IIS7 (pulled through python script):
[('content-length', '58'), ('x-powered-by', 'ASP.NET'), ('server', 'Microsoft-IIS/7.0'), ('date', 'Thu, 21 Oct 2010 15:51:28 GMT'), ('content-type', 'text/html'), ('www-authenticate', 'Negotiate, NTLM')]