0

当我尝试ContentType*.aspx页面上使用时,它工作正常。

Response.ContentType = ContentType;


但是当我尝试使用 on 时*.ascx,出现以下错误:

当前上下文中不存在名称“ContentType”


我应该如何解决这个问题?!

4

2 回答 2

1

右键单击您的错误并选择Resolve选项。可能有许多名称空间包含此类型,但请选择您在aspx.

于 2016-05-19T14:53:41.323 回答
1

尝试像这样设置它(假设我们正在设置文本/纯文本):

System.Web.HttpContext.Current.Response.ContentType = "text/plain";
于 2016-05-19T15:24:15.297 回答