简体   繁体   English

IIS7中的应用程序路径问题

[英]Problem with application path in IIS7

I am trying to add my application to a live server. 我正在尝试将我的应用程序添加到实时服务器中。 My site is in plain html. 我的网站是纯HTML。 There are 2 links to go my 2 application. 有2个链接可以访问我的2个应用程序。 I to go the siteapp and another to go to the main app. 我去siteapp,另一个去主程序。

In wwwroot I have added my site with a folder name(Lets saye MyWebSite) and configured it in IIS7 with dns ip address. 在wwwroot中,我使用文件夹名称(让我说MyWebSite)添加了我的站点,并在IIS7中使用dns ip地址对其进行了配置。 It works fine. 工作正常。

Then I added 2 more subfolder (siteapp & mainapp) for 2 application written in VS 2008 and conver them to application. 然后,我为VS 2008中编写的2个应用程序增加了2个子文件夹(siteapp和mainapp),并将其转换为应用程序。

So when I go to www.MyWebSite.com/mainAPP/Default.aspx - it works fine But if I click any button(forget password) in Default.aspx- it tries to access www.MyWebSite.com/ForgetPass.aspx and fail. 因此,当我访问www.MyWebSite.com/mainAPP/Default.aspx时-可以正常工作,但是如果我单击Default.aspx中的任何按钮(忘记密码),它将尝试访问www.MyWebSite.com/ForgetPass.aspx并失败。 It suppose to go to www.MyWebSite.com/mainAPP/ForgetPass.aspx but it goes to the root for some reason. 它应该去www.MyWebSite.com/mainAPP/ForgetPass.aspx,但是由于某种原因它已经进入了根目录。

If I click a normal a href="www.MyWebSite.com" link it goes to http://www.MyWebSite.com/MainApp/www.MyWebSite.com 如果我单击普通的href =“ www.MyWebSite.com”链接,它将转到http://www.MyWebSite.com/MainApp/www.MyWebSite.com

I have tried to catch it in global.asax page but no luck 我试图在global.asax页面中捕获它,但是没有运气

Code in Globacl.asax Globacl.asax中的代码

Application("AppPath") = ConfigurationSettings.AppSettings("ApplicationURL")
                If Application("AppPath") = "/" Then
                    Application("AppPath") = System.Configuration.ConfigurationManager.AppSettings("ApplicationPath")
                End If
                If Application("AppPath") <> System.Configuration.ConfigurationManager.AppSettings("ApplicationPath") Then
                    Application("AppPath") = System.Configuration.ConfigurationManager.AppSettings("ApplicationPath")
                End If

Code in web.config web.config中的代码

<add key="ApplicationURL" value="www.MyWebSite.com/mainAPP/"/>

I am using IIS7 我正在使用IIS7

Any idea how can I fix this? 知道我该如何解决吗?

All URLs within the page are relative to the website. 页面中的所有URL都是相对于网站的。 So if yo have your website in c:\\inetpub\\wwwroot, all URLs will be resolved based off that path. 因此,如果您的网站位于c:\\ inetpub \\ wwwroot中,则将根据该路径解析所有URL。 Try the following: 请尝试以下操作:

<add key="ApplicationURL" value="/mainAPP/"/>

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

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