IIS虚拟目录和ASP.NET目录路径 [英] IIS virtual directory and ASP.NET directory paths
问题描述
我遇到典型的虚拟目录的困境在你有你的ASP.Net应用程序的一些路径和部署在IIS虚拟目录的应用程序。然后,所有的亲戚路径的Web根目录(f.i.,/图像)不起作用,因为应用程序是在一个虚拟目录路径。
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. Then all paths relatives to the "web root" (f.i., "/images") doesn't work because the app is in a virtual directory path.
一个。使图片文件夹的虚拟目录。这样,/图像将一直存在。
A. Make the "images" folder a virtual directory. This way "/images" will always exist.
乙使用<%= Request.ApplicationPath%> / Imagenes
作为我的图片的来源。这在IIS的伟大工程,但我不能看到它在设计时也没有在调试时。
B. Use "<%=Request.ApplicationPath%>/Imagenes"
as the source of my images. This works great in IIS but I can't see it in design-time nor in debug-time.
此解决方案还包括这些说明:
This solution also include these instructions:
- System.Web.VirtualPathUtility.ToAbsolute
- ResolveClientUrl
- Request.ApplicationPath
℃。使用亲戚路径电流控制/页。这是知道确切位置的图像文件夹是相对于我目前的文件(没有去根,所以我会用像,../,../../等。
C. Use relatives paths to the current control/page. 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.
说的。我不喜欢这些解决方案。我想在web.config文件中或在IIS的解决方案。有些CONF按照压我在web.config文件中写,告诉IIS在我的应用程序实际驻留(虚拟目录)。
Said that. I don't like these solutions. I would want a solution in the web.config file or in IIS. Some conf intruction I write in the web.config file that tells IIS where my application resides actually (virtual directory).
任何意见?
推荐答案
您使用波浪号(〜)为你的路,你可以吗?
Are you using the tilde (~) for your paths where you can?
〜指虚拟Web应用程序的根....
~ refers to the root of the virtual Web application....
〜例如/图像。
这篇关于IIS虚拟目录和ASP.NET目录路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!