Search code examples
c#asp.netresponse.write

How to enable command Response.Write in C# (as referencing class for webapp ASP.NET)


I want to make procedure like this code below:

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

I've added using System.Web; but still there is an error in command response (The name 'Response' does not exist in current context).

How to solve this?


Solution

  • Try the full namespace:

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