Solved

Accessing Request.ServerVariables in a VB file

Posted on 2003-11-10
5
2,452 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 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