Solved

Accessing Request.ServerVariables in a VB file

Posted on 2003-11-10
5
2,421 Views
Last Modified: 2012-08-13
I am developing an ASP.NET Web Application and I have a .vb file that I working with. Within this .vb file I would like to be able to say:

Request.ServerVariables("SERVER_NAME")
Request.ServerVariables("PATH_INFO")

However, it seems that I am unable to access the "Request" object. Is there a way around this in a .vb file?

dtrick
0
Comment
Question by:dtrick
  • 2
  • 2
5 Comments
 
LVL 4

Assisted Solution

by:AdsB
AdsB earned 20 total points
ID: 9718887
Easiest way is as follows:-

in your .vb file you have a procedure...

Public Sub ProcName(ByVal CallingPage as Page)
   Dim servername as string

   servername = CallingPage.Request.ServerVariables("SERVER_NAME")
End Sub

Hope this helps,


AdsB
0
 

Expert Comment

by:theDIV
ID: 9721532
Hi dtrick

all you should need to do is use the httpcontext class as follows:

context.Request.ServerVariables("SERVER_NAME")
context.Request.ServerVariables("PATH_INFO")
0
 

Author Comment

by:dtrick
ID: 9724704
AdsB
How would you call this funtion? More specifically what does the parameter list look like?

theDIV
Is there a class library that I need to import? I tried to import "System.Web.HttpContext", but it didn't work.

Thanks,
dtrick
0
 

Accepted Solution

by:
theDIV earned 30 total points
ID: 9729729
dtrick,

I was using a class in my VB file which inherited from System.Web.UI.Page, making the context class directly available to me.  

If this isnt applicable to you, you can just dim a new httpcontext object, so your code would look like:

Dim context As HttpContext
context.Request.ServerVariables("SERVER_NAME")
context.Request.ServerVariables("PATH_INFO")
0
 

Author Comment

by:dtrick
ID: 9732588
Tried both.... and they work. Thanks a million!
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question