我应该使用Url.Content()或RESOLVEURL()在我的MVC的看法?我的、看法、Content、Url

由网友(与梦逃亡)分享简介:在构建code是这样的:When building code like this:或在构建code是这样的:

When building code like this:

<script type="text/javascript" src="<%=ResolveUrl("~/js/js.js")%>"></script>

<input type="image" src="<%=ResolveUrl("~/img/submit.png")%>" />

我应该使用 Url.Content RESOLVEURL()?有什么区别?

推荐答案

如果您使用的MVC应用程序中重写IIS的URL,例如在内部处理http://yoursubdomain.example.com/MyController/MyAction作为http://hosted.example.com/yoursubdomain/MyController/MyAction, Url.Content()会产生一个正确的子域相对链接。 RESOLVEURL()将产生在这种情况下,不正确的链接

If you're using IIS URL Rewriting within your MVC application, e.g. internally treating http://yoursubdomain.example.com/MyController/MyAction as http://hosted.example.com/yoursubdomain/MyController/MyAction, Url.Content() will generate a correct subdomain-relative link. ResolveUrl() will generate an incorrect link in this situation.

阅读全文

相关推荐

最新文章