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

查看:94
本文介绍了IIS 6网站root vs Application? RESOLVEURL()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我们遇到的问题是,同一组文件的行为会有所不同,具体取决于它是否有所不同是一个根IIS网站与IIS网站下的应用程序。使用 ResolveUrl 生成的网址()是不同的 - 即:

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. The urls produced using ResolveUrl() are different - i.e.:

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




  • 作为根网站,它产生: http://contact.aspx

  • 作为网站下的应用程序,它会产生: http://domainname.org/DSC/contact.aspx

    • As the root website, it produces: http://contact.aspx
    • As an application under a website, it produces: http://domainname.org/DSC/contact.aspx
    • 两者都使用相同的文件。第一个例子是它自己的网站,第二个例子是一个虚拟目录,它被制作成一个应用程序(名为DSC)。两者都使用相同的应用程序池,相同的配置,文档和安全设置(我确保两者之间的IIS中的所有设置都相同)。

      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). 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).

      所有的东西都有已经研究过表明ResolveUrl()确实引用了网页所在的IIS应用程序。我还阅读了几个地方,即使信息没有在IIS中完成(在这种情况下),根网站也被视为应用程序。因此,它应该产生适当的网址,但不是。

      Everything that has been researched indicates ResolveUrl() does refer to the IIS application that the webpage is under. 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. Therefore, it should produce the appropriate web address, but isnt.

      寻找更多研究以确定未正确设置哪些设置/配置的任何帮助,或者为什么ResolveUrl()不是应该以编程方式使用的。

      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.

      推荐答案

      检查出来:从ASP.NET中的相对路径到绝对路径而不使用Tilde~ 。您可以考虑用 HttpRuntime.AppDomainAppVirtualPath 替换您的波浪号(〜)用法。如果Web应用程序位于服务器根文件夹中,则 AppDomainAppVirtualPath 仅返回/。如果Web应用程序位于非根文件夹中,则返回文件夹的虚拟路径,最后没有/(来源)。

      Check this out: From Relative Path to Absolute Path in ASP.NET without using the Tilde ~. You might consider replacing your tilde (~) usage with HttpRuntime.AppDomainAppVirtualPath. If the web application is in a server root folder, AppDomainAppVirtualPath returns just "/". If web application is in a non-root folder it returns virtual path of the folder without "/" in the end (source).

      这篇关于IIS 6网站root vs Application? RESOLVEURL()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆