在ASP.net文件路径 [英] File paths in ASP.net
本文介绍了在ASP.net文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一般都是混了过去的问候文件路径(相对的,物理的,等等)。用我下面的项目结构:
I have gotten mixed up in the past with regards to file paths (relative, physical, etc.). With my following project structure:
Solution MySolution
- MyProject
-MiniApp Folder
-MiniApp.aspx
-Default.aspx
-Default2.aspx
请提供关于重定向的例子(前的Response.Redirect(〜/ Default.aspx的)。)从导航:
Please provide examples on redirection (ex. Response.Redirect("~/Default.aspx")) navigation from:
- 的Default.aspx到MiniApp.aspx
- MiniApp.aspx到Default.aspx的
- 的Default.aspx到Default2.aspx
使用:
- 物理路径
- 相对路径
- ,我已经省略任何其他路径
谢谢!
推荐答案
您不应该使用物理路径重定向。
you should NOT use physical path to redirect.
〜将解决您的应用程序的根目录/ MyProject的
~ will resolve to the root of YOUR APPLICATION /MyProject
在code以下会重定向到的任何网页
the code below will redirect to those pages from ANY PAGE
Response.Redirect("~/Default.aspx");
Response.Redirect("~/Default2.aspx");
Response.Redirect("~/MiniApp/MiniApp.aspx");
这篇关于在ASP.net文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文