Friday, March 25, 2011

Getting Access to the Response Object from a Regular C# Class (and NOT a code-behind)

When I attempt to call Response.Write() or Response.Redirect() from a genuine C# class (NOT a code-behind), I get an interesting error:

"Response is not available in this context."

However, call it this way and it should work fine:

HttpContext.Current.Response.Write("Hello, World!");

No comments:

Post a Comment