asp.netcontenttype

ContentType on ascx returns error


When I'm trying to use ContentType on *.aspx page, it is working fine.

Response.ContentType = ContentType;


But when I'm trying to use on *.ascx, following error occurred:

The name 'ContentType' does not exist in the current context


how I should resolve this issue ?!


Solution

  • Try setting it like this (say we're setting text/plain):

    System.Web.HttpContext.Current.Response.ContentType = "text/plain";