We help IT Professionals succeed at work.

System.Web.HttpException: Request is not available in this context

dba123 asked
Last Modified: 2009-12-16
I want to make a couple variables global within my page so that I do not have to keep redefining them in each method.  I tried moving these out of Page_Load

    Dim StudentID As Integer = Request.QueryString("syStudentID")
    Dim LeadID As Integer = GetmkLeadID(StudentID)

I get this: System.Web.HttpException: Request is not available in this context
Watch Question

Jai STech Arch

if you want them as global dont declare them in the page_load

declare them in your form decaration part and use them in the page_load
StudentId = Request.QueryString("sdfd")

Query String can be accessed in page_load
Unlock this solution and get a sample of our free trial.
(No credit card required)


I had them declared in the Page_Load initially....but that didn't guarantee that all methods could see it.
Jai STech Arch

why was the point not split...it was me who answered the question first...


Because the answer is this.

1) Declare the variables but don't initialize them in the class, before the Page_Load
2) Initialize the variable in the Page_Load only

I had to separate the two out.  Your sentences didn't suggest this or were at least not clear to me.
Jai STech Arch

thnk you so much...i will post this to the community advisor and will ask for his suggestion...
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.