简体   繁体   English

IIS 6网站根与应用程序? ResolveUrl()?

[英]IIS 6 Website root vs Application? ResolveUrl()?

IIS 6 ASP.NET 3.5 (C#.NET) IIS 6 ASP.NET 3.5(C#.NET)

We are having an issue where the same set of files behave differently depending on if it is a root IIS website versus an application under an IIS website. 我们遇到的一个问题是,同一文件集的行为会有所不同,具体取决于它是IIS的根网站还是IIS网站下的应用程序。 The urls produced using ResolveUrl () are different - ie: 使用ResolveUrl ()生成的网址是不同的-即:

<a href="<%=ResolveUrl("~/contact.aspx") %>">Contact Us</a>

Both are utilizing the same files. 两者都利用相同的文件。 The first example is its own website, the second is a virtual directory made into an application (titled DSC). 第一个示例是其自己的网站,第二个示例是进入应用程序(标题为DSC)的虚拟目录。 Both also use the same application pool, and same configuration, document and security settings (I made sure all the settings were the same in IIS between both). 两者都使用相同的应用程序池,以及相同的配置,文档和安全设置(我确保两者之间的IIS中的所有设置都相同)。

Everything that has been researched indicates ResolveUrl() does refer to the IIS application that the webpage is under. 研究的所有内容都表明ResolveUrl()确实引用了该网页所在的IIS应用程序。 I have also read several places that even if the information isnt completed in IIS (in this case it is), a root website is considered an application. 我还读过几个地方,即使信息未在IIS中完成(在本例中是),也将根网站视为应用程序。 Therefore, it should produce the appropriate web address, but isnt. 因此,它应该产生适当的网址,但不是。

Any help in finding more research to determine what settings/configuration is not set appropriately, or why ResolveUrl() is not what should be used programmatically. 查找更多研究以确定任何设置/配置未正确设置的任何帮助,或为什么不以编程方式使用ResolveUrl()的任何帮助。

Check this out: From Relative Path to Absolute Path in ASP.NET without using the Tilde ~ . 检查一下: 从ASP.NET中的相对路径到绝对路径,而无需使用Tilde〜 You might consider replacing your tilde (~) usage with HttpRuntime.AppDomainAppVirtualPath . 您可以考虑使用HttpRuntime.AppDomainAppVirtualPath代替波浪号(〜)用法。 If the web application is in a server root folder, AppDomainAppVirtualPath returns just "/". 如果Web应用程序位于服务器根文件夹中,则AppDomainAppVirtualPath仅返回“ /”。 If web application is in a non-root folder it returns virtual path of the folder without "/" in the end ( source ). 如果Web应用程序位于非根文件夹中,则它将返回该文件夹的虚拟路径,其末尾不带“ /”( )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM