惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
V
V2EX
Jina AI
Jina AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
量子位
L
LangChain Blog
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
腾讯CDC
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss

博客园 - Liu Jian

C#的栈(Stack)和堆(Heap) A low-level Look at the ASP.NET Architecture(引自:http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp 从底层了解ASP.NET架构(引自:http://tech.it168.com/msoft/2007-12-24/200712241034626.shtml) [Joe 原创]Web Control 开发系列(四) Validation机制 [转贴]使用ADO.NET2.0提升数据交互性能(http://dotnet.chinaitlab.com/ADONET/739268.html) - Liu Jian - 博客园 Define a Custom Control Builder for a Custom Server Control(http://www.aspnetpro.com/newsletterarticle/2006/05/asp200605de_l/asp200605de_l.asp) [Joe 原创]Web Control 开发系列(三) 解析IPostBackEventHandler和WebForm的事件机制 [Joe 原创] Web Control 开发系列(二) 深入解析Page的PostBack过程和IPostBackDataHandler [Joe 原创]Web Control 开发系列(一) 页面的生命周期 Web Control 开发系列 之 前言 ASP.NET MVC 学习: 视图(http://whx.tzgt.gov.cn/newOperate/html/1/12/123/12058.html) ASP.NET MVC框架(第一部分)(http://blog.joycode.com/scottgu/archive/2007/11/14/111385.aspx) (转贴的)如何开发Firefox插件 Cross Domain XmlHttpRequests (http://benreichelt.net/blog/2005/4/11/Cross-Domain-XmlHttpRequests-Ajax/) Cross Domain XmlHttpRequests (http://benreichelt.net/blog/2005/4/11/Cross-Domain-XmlHttpRequests-Ajax/) 跨域(cross-domain)访问 cookie (读取和设置)(http://www.dup2.org/node/384) ajax跨域和js跨域解决方案(http://hi.baidu.com/longniao/blog/item/ce5e9cca3e2a4782c817684d.html) Javascript 内存泄漏问题(http://hi.baidu.com/webworker/blog/item/25f9f0dcf14d51a2cc116671.html) JavaScript内存泄漏(http://www.blogjava.net/tim-wu/archive/2006/05/29/48729.html)
关于ResolveClientUrl和ResolveUrl的使用 问题 (http://www.c...
Liu Jian · 2008-06-24 · via 博客园 - Liu Jian

两个方法都是传递一个相对的 URL,然后返回一个相对于当前客户端浏览器的相对URL地址
但是两者的返回值,却截然不同
ResolveClientUrl返回相对于当前页面下文件的地址
ResolveUrl则返回页面所在应用程序下的相对地址
例如:
页面:~/Student/main.aspx
图像:~/Images/copy.gif
(这里~表示应用程序根目录)
使用一:
resolveClientUrl=Page.ResolveClientUrl("Images/copy.gif")
resolveUrl=Page.ResolveUrl("Images/copy.gif")
在页面main.aspx里使用copy.gif图像,则使用标题上的两种方法返回的结果如下
ResolveClientUrl:Images/copy.gif
ResolveUrl:/Student/Images/copy.gif


使用二:
resolveClientUrl=Page.ResolveClientUrl("~/Images/copy.gif")
resolveUrl=Page.ResolveUrl("~/Images/copy.gif")
在页面main.aspx里使用copy.gif图像,则使用标题上的两种方法返回的结果如下
ResolveClientUrl:../Images/copy.gif
ResolveUrl:/Images/copy.gif


结论
所以在使用ResolveClientUrl和ResolveUrl的时候一定要注意两者的区别
在使用相对URL地址时一定要在前面加上(~)或(~/),这样就万无一失了
不过使用这两种方法返回的物理路径(Server.MapPath),都是一样的