MVC @ Url.Content VS @ Url.Action [英] MVC @Url.Content vs @Url.Action

查看:512
本文介绍了MVC @ Url.Content VS @ Url.Action的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上看了,但没能找到有什么区别之间
使用@ Url.Content VS @ Url.Action

I have looked online but was not able to find what the difference is between using @Url.Content vs @Url.Action

推荐答案

当你想解决一个网址的任何文件或您网站上的资源Url.Content使用,你会通过它的相对路径:

Url.Content is used when you wish to resolve a url for any file or resource on your site and you would pass it the relative path:

@Url.Content("~/path/file.htm")

Url.Action用来解析从控制器,如一个动作:

Url.Action is used to resolve an action from a controller such as:

@Url.Action("ActionName", "ControllerName", new { variable = value })

在这里看到更多的信息:

See here for more info:

<一个href=\"http://geekswithblogs.net/liammclennan/archive/2008/05/21/122298.aspx\">http://geekswithblogs.net/liammclennan/archive/2008/05/21/122298.aspx

这篇关于MVC @ Url.Content VS @ Url.Action的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆