MVC @ Url.Content VS @ Url.Action

编程入门 行业动态 更新时间:2024-10-23 08:24:39
本文介绍了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:

geekswithblogs/liammclennan/archive/2008/05/21/122298.aspx

更多推荐

MVC @ Url.Content VS @ Url.Action

本文发布于:2023-11-02 08:17:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551863.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Url   MVC   Action   Content

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!