Last active
February 18, 2019 02:22
-
-
Save huanlin/6086030 to your computer and use it in GitHub Desktop.
ASP.NET URL and Path related methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Related Properties | |
- HttpRuntime.AppDomainAppVirtualPath | |
- Request.ApplicationPath | |
Methods for getting physical file path: | |
- System.Web.HttpContext.Current.Server.MapPath() | |
Methods for generating content URL: | |
- System.Web.UI.Control.ResolveUrl() or Page.ResolveUrl() | |
- System.Web.Mvc.UrlHelper.GenerateContentUrl() | |
- System.Web.VirtualPathUtility.ToAbsolute() | |
Example of UrlHelper.GenerateContentUrl: | |
var context = new HttpContextWrapper(HttpContext.Current); | |
string url = UrlHelper.GenerateContentUrl("~/Images/photo.jpg, context); | |
References | |
- ResolveUrl in ASP.NET - The Perfect Solution | |
http://www.codeproject.com/Articles/53460/ResolveUrl-in-ASP-NET-The-Perfect-Solution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment