HOW TO GET .NET HTTPCONTEXT FOR ISOLATED CODE BLOCK

john rob

Total Post:108

Points:756
Posted by  john rob
 1009  View(s)
Ratings:
Rate this:

In .NET is it possible to get the HttpContext of the current page from within an external class?

So, for example in my page test1.aspx codebehind I've got:

    Dim blah As New FeedWriter()

    blah.Run()

But inside FeedWriter.vb, can I get the HttpContext of test1.aspx? Or would I have to pass it in to Run()? (I'm unwilling to do the latter because FeedWriter implements an interface which will need to be re-written if it's to take arguments)

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to get .NET HttpContext for isolated code block

    Hi John, 

    You can use the Current property of the HttpContext class:

    HttpContext.Current;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!