&是什么QUOT;〜/"解析为ASP:当前文件夹或网站的根? [英] What does "~/" resolve to in ASP: the current folder or the root of the website?
问题描述
确实使用〜/在一个文件路径解析到当前文件夹或网站的根?
does using ~/ in a file path resolve to the root of the current folder or the website?
我有一个文件结构这样:
I have a file structure as such:
\
->Folder
-->Page1.Aspx
->App_Themes
-->Theme1
--->Images
--->StyleSheet.css
->Includes
-->Footer.htm
Default.aspx
Default.master
我用我的default.master页面Page1.aspx的和Default.aspx的。母版页使用<! - #包括文件=包括/ Footer.htm - >
。然后在我的Footer.html我用路径,图像,例如:〜/ App_Themes文件/ THEME1 /图片/ Image1.png
I am using my default.master page for Page1.aspx and default.aspx. The master page uses <!-- #include file="includes/Footer.htm" -->
. Then in my Footer.html i use paths for images such as : ~/App_Themes/Theme1/Images/Image1.png".
图片将会Default.aspx中正常显示,但不会在Page1.aspx的发现。我想〜/意味着该网站的根文件路径中使用时?
The image will display properly in default.aspx but will not be found in Page1.aspx. I thought ~/ meant root of the website when used in a file path?
编辑:
我错了,它也不会defaut.aspx工作。这是工作的路径是:/App_Themes/Theme1/Images/Image1.png。
I was wrong, it is also not working in defaut.aspx. The path that was working is: /App_Themes/Theme1/Images/Image1.png.
推荐答案
它解析为当前Web应用程序的根目录下,这可能会或可能不会是网站作为一个整体的根源。
It resolves to the root of the current web application, which may or may not be the root of the website as a whole.
要理解上的差异,请参阅这篇文章。
To understand the difference, see this article.
作为一般规则,当你创建一个网站,或在Visual Studio中的Web应用程序,实际上是建立在IIS中Web应用程序说话。
As a general rule, when you're creating a "website" or a "web application" in Visual Studio, you're actually creating a "Web Application" in IIS speak.
要进一步搅浑水,从概念上讲,该网站的根在自身和IIS应用程序,这样您就可以发布的Visual Studio网站/网络应用程序到您的网站的根目录。在这种情况下,〜/将参考网站的根
To further muddy the waters, Conceptually, the root of the website is an IIS "application" in and of itself, so you can publish your Visual Studio website/web application to the root of your website. In that case, ~/ will refer to the root of the site.
不过,如果你有多个应用程序都在一个网站上运行,那么每一个在〜/将引用该应用程序的根目录。
If, however, you've got multiple Applications all running in one Site, then in each one the ~/ will refer to the root of that application.
举例来说,假设有MySite.com不同的应用
For example, say MySite.com has different applications
- mySite.Com - 在Visual Studio鲜明的应用程序,具有普遍的网站内容。
- mySite.Com/shop有一个购物车。这是在Visual Studio中一个独特的应用程序,和明显的IIS应用程序。
- MySite.Com/Support包含了客户支持一个独立的,不同的应用程序。票务提交,与接线员等聊天。
在上述所有的,mysite.com是网站。但/ *表示该应用程序。在〜/将把
In all of the above, mysite.com is the website. but the /* denotes the application. The ~/ will refer to
- mySite.Com/
- mySite.Com/shop /
和
- MySite.Com/Support /
这篇关于&是什么QUOT;〜/&QUOT;解析为ASP:当前文件夹或网站的根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!