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

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - Du大调

mysql 8 忘记密码 发生系统错误 1067 一些有特色的国外电子商务网站 margin在IE6下的问题。 4月4号参加北京俱乐部活动的收获 转化率极高的十个网站 使用aspnet_regsql.exe 创建ASPState数据库,用来保存session会话 (转)获取网购订单的12个技巧 利用委托异步发送邮件 每日词汇 每日英语 词汇 不是可以识别的 内置函数名称 电子商务网站用户体验--根据用户的习惯进行推荐 异常详细信息: System.Data.SqlClient.SqlException:过程或函数 需要参数 但未提供该参数。 在IIS中设置Gzip页面压缩 刚做项目的时候 silverlight 不可 silverlight error message,ErrorCode:2254 ErrorCode: 1001 响应在此上下文中不可用
不是有效的虚拟路径,未能映射路径
Du大调 · 2008-05-19 · via 博客园 - Du大调

今天要写一段读写文件的程序,使用this.Server.MapPath(str),str是一路径字符串,如:http://localhost/web/index.html
,不料却出现“不是有效的虚拟路径”的错误,马上检查程序,感觉没有什么错误,于是乎网上搜,
找啊找,就是找不到解决方案。只有自己慢慢调试了;
先使用了一个根路径"/",居然换了一个错误:“未能映射路径”,就搜这个错误,这个还有相应的回答:
把"/"换成"~/",成功了。心窃喜。。。
于是先把str.ToLower(),然后str.Replace("http://","");接着str.SubString(str.IndexOf("/"));
最后str = "~"+str;
this.Server.MapPath(str);
成功。。。
代码如下:

1 str = str.ToLower();
2 if(str.IndexOf("http://"> -1)
3                 {
4                     str = str.Replace("http://","");
5                     str = str.Substring(str.IndexOf("/"));
6                 }
7                 str = this.Server.MapPath("~"+str);


本博客内容公供学习研究用,和工作内容无关.