Thursday, March 28, 2013

Generate URL from local path in ASP.NET


string url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + Request.ApplicationPath + "/PDF/MyFile.pdf";

Above string will generate a URL like below.

http://localhost:8630/PDFGenerator/PDF/MyFile.pdf

No comments:
Write comments
Recommended Posts × +