ASP.Net Error: Response is not available in this context

This error occurred when  i tried to call Response.Redirect method from a class file. Then i tried to find the solution and i got to know that when we use the response object from an aspx page either from aspx page or it’s codebehind page, the response object is directly available because all these derived from the page object.

When we use the response object in our own class, the object is not directly available, so we got this message.

But we can use it by the following method :

HttpContext.Current.Response.Redirect(http://google.com“);

Same problem happens when we tried to call a function from Response object.

Thank You.

Posted

in

by

Tags:


Related Posts

Comments

2 responses to “ASP.Net Error: Response is not available in this context”

  1. jitendra Avatar

    Good article sahoo,
    it didn’t came in my experience.
    will try to reproduce same so that i can be benefited too.

  2. Josfalme Avatar
    Josfalme

    Excellent! Thanks a lot!

Leave a Reply to JosfalmeCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading