• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2380
  • Last Modified:

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

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
0
dba123
Asked:
dba123
  • 3
  • 2
1 Solution
 
Jai STech ArchCommented:
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
0
 
sujithcnairCommented:
Make sure you have declared the variable between the partial class declaration and page load function

Partial Class description
    Inherits System.Web.UI.Page
    Dim StudentID As Integer
    Dim LeadID As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
   
    End Sub
0
 
dba123Author Commented:
I had them declared in the Page_Load initially....but that didn't guarantee that all methods could see it.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Jai STech ArchCommented:
why was the point not split...it was me who answered the question first...
0
 
dba123Author 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.
0
 
Jai STech ArchCommented:
thnk you so much...i will post this to the community advisor and will ask for his suggestion...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now