开发者

IIS 6 Website root vs Application? ResolveUrl()?

开发者 https://www.devze.com 2023-02-15 11:18 出处:网络
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.The urls produced

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

<a href="<%=ResolveUrl("~/contact.aspx") %>">Contact Us</a>
  • As the root website, it produces: http://contact.aspx
  • As an application under a website, it produces: http://domainname.org/DSC/contact.aspx
开发者_运维问答

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

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.

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消