Getting virtual path of a web page from a web service in c #

I want to get the virtual path of a web page from a web service. Is there any way to do this ?. Let's say I have an aspx page like aa, I want to get the full path as url for this page from my web service.

Best regards, Severe Suman

+1


source to share


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


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







All Articles