Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Accessing Request.ServerVariables in a VB file

Posted on 2003-11-10
5
Medium Priority
?
2,515 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 80 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 120 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline
Suggested Courses

772 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