Wednesday, January 19, 2011

Using Current.Response in Custom Class

ASP.NET

Problem:

When using Current.Response in a custom ASP.NET class there are compiler errors e.g.

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

The type or namespace name 'HttpContext' does not exist in the namespace 'System.Web' (are you missing an assembly reference?

Solution:

  1. Add System.Web as a reference to the class.  Right click the class in the Solution Explorer and choose Add Reference. On the .NET tab select System.Web.
  2. Insert the following at the top of the class: using System.Web;

No comments:

Post a Comment