Solved

Accessing Request.ServerVariables in a VB file

Posted on 2003-11-10
5
2,392 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now