如何在子文件夹中托管ASP.NET MVC站点

时间:2023-02-07 04:02:45

I'm trying to run a little ASP.NET project in a subfolder of my hosting. My domain is www.gorangligorin.com, but i want to run my app in www.gorangligorin.com/testmvc. ASP.NET MVC runs with no problems on the top level, but not in subfolders.

我正在尝试在我的托管的子文件夹中运行一个小的ASP.NET项目。我的域名是www.gorangligorin.com,但我想在www.gorangligorin.com/testmvc中运行我的应用程序。 ASP.NET MVC在*运行时没有问题,但在子文件夹中没有问题。

The server says this (line 58 is colored red):

服务器说这个(第58行是红色的):

Line 56:             ASP.NET to identify an incoming user. 
Line 57:     -->
Line 58:     <authentication mode="Forms">
Line 59:       <forms loginUrl="~/Account/LogOn" timeout="2880" />
Line 60:     </authentication>

What can I do to make this ASP.NET MVC website work? This isn't hosted on my computer, so I don't have access to IIS configirations.

我该怎么做才能使这个ASP.NET MVC网站工作?这不在我的计算机上托管,因此我无权访问IIS配置。

4 个解决方案

#1


3  

Did you create a ASP.NET Application in IIS for this directory? Otherwise ASP.NET thinks the root of your server is the root of your application, not the one in the subdirectory.

您是否在IIS中为此目录创建了ASP.NET应用程序?否则,ASP.NET认为服务器的根是应用程序的根,而不是子目录中的根。

#2


5  

The settings of the root application in your IIS may affect your children apps. In order to prevent the root settings from propagating, insert the following code in your root web.config:

IIS中根应用程序的设置可能会影响您的子应用程序。为了防止根设置传播,请在根web.config中插入以下代码:

<location path="." inheritInChildApplications="false"/>

Hope this helps.

希望这可以帮助。

#3


1  

Did you try the following?

你试过以下吗?

<forms loginUrl="~/testmvc/Account/LogOn" timeout="2880" />

The tilde (~) is a shortcut for the HttpRuntime.AppDomainAppVirtualPath property, which refers to the virtual application root, not the root of the web server.

代字号(〜)是HttpRuntime.AppDomainAppVirtualPath属性的快捷方式,该属性引用虚拟应用程序根目录,而不是Web服务器的根目录。

HttpRuntime.AppDomainAppVirtualPath

http://msdn.microsoft.com/en-us/library/system.web.httpruntime.appdomainappvirtualpath.aspx

http://msdn.microsoft.com/en-us/library/system.web.httpruntime.appdomainappvirtualpath.aspx

Also, what is up the asterisk?

另外,星号是什么?

Line 58:     <authentication mode="Forms">*

#4


1  

There are Mainly two reasons for this issue:

这个问题主要有两个原因:

  1. If you Have not configured your asp.net application in IIS as in to set that Virtual Directory as an Application

    如果您尚未在IIS中配置asp.net应用程序,则将虚拟目录设置为应用程序

  2. Two or many Web.Config Exists on your Site. Since you have the web.config at the root level and the second web.config in the sub-directory. So just remove that web.config if its the same . or go back to 1 and solve it accordingly in the IIS

    您网站上存在两个或多个Web.Config。由于您在根级别具有web.config,在子目录中具有第二个web.config。所以只要删除那个web.config,如果它是相同的。或者回到1并在IIS中相应地解决它

    And since you added a subdirectory from root, I would say that you have to change your routes in the global.asax file, to handle the routing

    既然你从root添加了一个子目录,我会说你必须在global.asax文件中更改路由,以处理路由

Url = "testmvc/{controller}/{action}/{id}"

Url =“testmvc / {controller} / {action} / {id}”

#1


3  

Did you create a ASP.NET Application in IIS for this directory? Otherwise ASP.NET thinks the root of your server is the root of your application, not the one in the subdirectory.

您是否在IIS中为此目录创建了ASP.NET应用程序?否则,ASP.NET认为服务器的根是应用程序的根,而不是子目录中的根。

#2


5  

The settings of the root application in your IIS may affect your children apps. In order to prevent the root settings from propagating, insert the following code in your root web.config:

IIS中根应用程序的设置可能会影响您的子应用程序。为了防止根设置传播,请在根web.config中插入以下代码:

<location path="." inheritInChildApplications="false"/>

Hope this helps.

希望这可以帮助。

#3


1  

Did you try the following?

你试过以下吗?

<forms loginUrl="~/testmvc/Account/LogOn" timeout="2880" />

The tilde (~) is a shortcut for the HttpRuntime.AppDomainAppVirtualPath property, which refers to the virtual application root, not the root of the web server.

代字号(〜)是HttpRuntime.AppDomainAppVirtualPath属性的快捷方式,该属性引用虚拟应用程序根目录,而不是Web服务器的根目录。

HttpRuntime.AppDomainAppVirtualPath

http://msdn.microsoft.com/en-us/library/system.web.httpruntime.appdomainappvirtualpath.aspx

http://msdn.microsoft.com/en-us/library/system.web.httpruntime.appdomainappvirtualpath.aspx

Also, what is up the asterisk?

另外,星号是什么?

Line 58:     <authentication mode="Forms">*

#4


1  

There are Mainly two reasons for this issue:

这个问题主要有两个原因:

  1. If you Have not configured your asp.net application in IIS as in to set that Virtual Directory as an Application

    如果您尚未在IIS中配置asp.net应用程序,则将虚拟目录设置为应用程序

  2. Two or many Web.Config Exists on your Site. Since you have the web.config at the root level and the second web.config in the sub-directory. So just remove that web.config if its the same . or go back to 1 and solve it accordingly in the IIS

    您网站上存在两个或多个Web.Config。由于您在根级别具有web.config,在子目录中具有第二个web.config。所以只要删除那个web.config,如果它是相同的。或者回到1并在IIS中相应地解决它

    And since you added a subdirectory from root, I would say that you have to change your routes in the global.asax file, to handle the routing

    既然你从root添加了一个子目录,我会说你必须在global.asax文件中更改路由,以处理路由

Url = "testmvc/{controller}/{action}/{id}"

Url =“testmvc / {controller} / {action} / {id}”