We help IT Professionals succeed at work.

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

dba123
dba123 asked
on
2,567 Views
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
Comment
Watch Question

Jai STech Arch

Commented:
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)
UNLOCK SOLUTION

Author

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

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

Author

Commented:
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

Commented:
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.

OR

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.