例如,ASP.NET虚拟路径在哪里解析~链接中 的波浪号
<link rel="stylesheet" type="text/css" href="~/Css/Site.css" />
Run Code Online (Sandbox Code Playgroud)
它重定向,还是RedirectToAction在ASP.NET MVC中?
Ali*_*tad 20
从这里得到它:
VirtualPathUtility.ToAbsolute(contentPath, httpContext.Request.ApplicationPath);
Run Code Online (Sandbox Code Playgroud)
这是System.Web.Mvc DLL中PathHelpers类的反射器输出:
private static string GenerateClientUrlInternal(HttpContextBase httpContext, string contentPath)
{
if (string.IsNullOrEmpty(contentPath))
{
return contentPath;
}
if (contentPath[0] == '~')
{
string virtualPath = VirtualPathUtility.ToAbsolute(contentPath, httpContext.Request.ApplicationPath);
string str2 = httpContext.Response.ApplyAppPathModifier(virtualPath);
return GenerateClientUrlInternal(httpContext, str2);
}
NameValueCollection serverVariables = httpContext.Request.ServerVariables;
if ((serverVariables == null) || (serverVariables["HTTP_X_ORIGINAL_URL"] == null))
{
return contentPath;
}
string relativePath = MakeRelative(httpContext.Request.Path, contentPath);
return MakeAbsolute(httpContext.Request.RawUrl, relativePath);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13176 次 |
| 最近记录: |