In C# in an asmx web service how do I get the current domain that the webservice was called on? HttpContext.Current.Request.Url.Host returns kindof what I want but instead of http://mydomain.com/Folder/Mywebservice.asmx I just need http://mydomain.com. I know i could just cut that string up but it seems really in-elegant. Thanks
+2
A:
Possible duplicate of the link below -
You will get answer here.
Sachin Shanbhag
2010-08-04 09:42:21
+1
A:
Uri.GetLeftPart
helps here:
Request.Url.GetLeftPart(UriPartial.Authority)
Tim Robinson
2010-08-04 09:44:45
A:
In VB.Net I have used...
With HttpContext.Current.Request.Url
sDomain=.Scheme & System.Uri.SchemeDelimiter & .Host
End With
Or if you care about the Port then...
With HttpContext.Current.Request.Url
sDomain=.Scheme & System.Uri.SchemeDelimiter & .Host & IIf(.IsDefaultPort,"",":") & .Port
End With
Should be easy to convert to C# ;)
barrylloyd
2010-08-04 09:47:40