[英]IIS virtual directory and ASP.NET directory paths
I'm running into the typical virtual-directory dilemma in that you have some paths on your ASP.Net application and you deploy the app in a IIS virtual directory. 我遇到了典型的虚拟目录困境,因为您在ASP.Net应用程序上有一些路径,并且您将应用程序部署在IIS虚拟目录中。 Then all paths relatives to the "web root" (fi, "/images") doesn't work because the app is in a virtual directory path.
然后所有与“web根”(fi,“/ images”)相关的路径都不起作用,因为应用程序位于虚拟目录路径中。
A. Make the "images" folder a virtual directory. A.将“images”文件夹设为虚拟目录。 This way "/images" will always exist.
这样“/ images”将永远存在。
B. Use "<%=Request.ApplicationPath%>/Imagenes"
as the source of my images. B.使用
"<%=Request.ApplicationPath%>/Imagenes"
作为我的图像的来源。 This works great in IIS but I can't see it in design-time nor in debug-time. 这在IIS中很有用,但我无法在设计时和调试时看到它。
This solution also include these instructions: 此解决方案还包括以下说明:
C. Use relatives paths to the current control/page. C.使用当前控件/页面的亲戚路径。 This is know exactly where the images folder is relative to my current file (without go to the root. So I would use things like "", "../", "../../" and so on.
这确切地知道images文件夹相对于我当前文件的位置(没有转到root。所以我会使用像“”,“../”,“../../”之类的东西等等。
Said that. 说。 I don't like these solutions.
我不喜欢这些解决方案。 I would want a solution in the web.config file or in IIS.
我想在web.config文件或IIS中找到解决方案。 Some conf intruction I write in the web.config file that tells IIS where my application resides actually (virtual directory).
我在web.config文件中写了一些内容,告诉IIS我的应用程序实际驻留在哪里(虚拟目录)。
Any advice? 有什么建议?
Are you using the tilde (~) for your paths where you can? 你在路径上使用波浪号(〜)吗?
~ refers to the root of the virtual Web application.... 〜指的是虚拟Web应用程序的根....
~/images for example. 〜/图像例如。
If it's just for css files on the client side then using the url directive makes the path relative to that of the style sheet rather than the page: 如果只是客户端的css文件,则使用url指令使路径相对于样式表而不是页面:
h1#title { background: url('dog.gif') no-repeat 0 0; }
Also if you're on asp.net mvc then you have access to: 此外,如果您使用的是asp.net mvc,那么您可以访问:
<script src="<%= Url.Content("~/scripts/new.js") %>" type="text/javascript"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.