Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Accessing Host Header within Web Services Method

Posted on 2004-11-01
5
Medium Priority
?
400 Views
Last Modified: 2012-06-27
I have a web service that I need to retreive the host header used to access the service.  In classic ASP, I would use Request.ServerVariables("SERVER_NAME"), but I am having a hard time doing this from within VB.NET.  In the web services "code-behind" (myservice.asmx.vb) page, I don't have access to the Request object, and if I try to use System.Web.HttpRequest object, it doesn't provide for any properties like ServerVariables, it only provides Equals and ReferenceEquals in the IntelliSense dropdowns.  I just need to be able to determine the difference if the web service is being accessed via:
     http://test1.mysite.com/myservice.asmx/mymethod
as opposed to:
     http://test2.mysite.com/myservice.asmx/mymethod

Any help is appreciated!
0
Comment
Question by:bmccleary
[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 22

Accepted Solution

by:
CJ_S earned 1600 total points
ID: 12466043
Try using the current httpcontext. Like

System.Web.HttpContext.Current().Request.ServerVariables("SERVER_NAME")

CJ.

0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12466058
Dim en As System.Collections.IEnumerator

en = Request.Headers.GetEnumerator

While en.MoveNext
   Response.Write(CStr(en.Current) & "<br>")
End While

Or

Dim en As System.Collections.IEnumerator

en = Request.Headers.GetEnumerator

While en.MoveNext
   Response.Write(CStr(en.Current) & "<br>")
End While
0
 

Author Comment

by:bmccleary
ID: 12466517
Thanks Aeros, but the problem is that I don't have access to the Request or Response objects.  When I put that code in my asmx page, it underscores bothe the Request and Response lines and states "Name 'Request' is not declared.".  My web service class inherits from System.Web.Services.WebService and the following are my imports clauses:

Imports System.Web.Services
Imports System.Text

Do I need another Imports statement?
0
 
LVL 17

Assisted Solution

by:AerosSaga
AerosSaga earned 400 total points
ID: 12466552
try imports system.web
0
 

Author Comment

by:bmccleary
ID: 12467947
Thanks guys.  CJ, I didn't see your comment the first time, but that worked.  Aeros, thank you also, that seems to work as well.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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