如何在C#中启用命令Response.Write(作为webapp ASP.NET的引用类)

时间:2015-06-26 07:25:21

标签: c# asp.net response.write

我想制作如下代码的程序:

void accessBySession(String user, String webqname)
{
  ...
  Response.Write("<script>alert('You can't access this page !');document.location='dashboard.aspx'; </script>  ");
}

我添加了using System.Web;,但命令响应仍有错误(名称&#39;响应&#39;在当前上下文中不存在。)

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

尝试完整的命名空间:

System.Web.HttpContext.Current.Response.Write("<script>alert('You can't access this page !');document.location='dashboard.aspx'; </script>)