Control.ResolveUrl与Control.ResolveClientUrl与VirtualPathUtility.ToAbsolute [英] Control.ResolveUrl versus Control.ResolveClientUrl versus VirtualPathUtility.ToAbsolute

查看:197
本文介绍了Control.ResolveUrl与Control.ResolveClientUrl与VirtualPathUtility.ToAbsolute的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有benifit解决它与波浪线开始路径时使用这些方法在另一个(〜)?

Is there any benifit to using one of these methods over the other when resolving paths which start with the tilde (~)?

一般情况下,什么是更好的做法,如果你是送你的HTML相对路径或绝对路径了吗?

Generally, what is a better practice, should you be sending relative paths or absolute paths down in your html?

推荐答案

RESOLVEURL和ResolveClientUrl之间的不同之处在于ResolveClientUrl返回路径相对于当前页面,RESOLVEURL路径相对于返回到网站根目录:

The difference between ResolveUrl and ResolveClientUrl is that ResolveClientUrl returns a path relative to the current page, ResolveUrl returns a path relative to the site root:

<一个href="http://www.andornot.com/blog/post/ResolveUrl-vs-ResolveClientUrl.aspx">http://www.andornot.com/blog/post/ResolveUrl-vs-ResolveClientUrl.aspx

我会建议使用绝对路径。

I would recommend using absolute paths.

修改:里克施特拉尔张贴有关这是一个不错的文章

Edit: Rick Strahl posted a nice article about this

EDIT2 :有关缓存移除位。不添加到应答并且不一定是准确

Edit2: Removed bit about caching. Does not add to the answer and may not necessarily be accurate.

<一个href="http://west-wind.com/weblog/posts/132081.aspx">http://west-wind.com/weblog/posts/132081.aspx

这篇关于Control.ResolveUrl与Control.ResolveClientUrl与VirtualPathUtility.ToAbsolute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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