Getting virtual path of a web page from a web service in c #
2 answers
What type of web service? ASMX? or wcf (svc)?
With asmx you can use HttpContext.Current
ASP.NET to get the current request so you can get pretty much anything you can get with ASP.NET; try looking at the property .Request
HttpContext.Current
.
This is not recommended with wcf - but it can be made to work if you enable ASP.NET compatibility.
+1
source to share
I agree with the above message. You can use the HttpContext.Current.Request object to access the virtual path and request url.
string path = HttpContext.Current.Request.ApplicationPath;
or if you want to get the full url:
string path = HttpContext.Current.Request.Url.OriginalString;
0
source to share