IIS 7中虚拟目录ASP.NET网站的配置错误

5
这可能是许多问题中的一个,但我正在尝试缩小问题来源范围,以查明我的IIS设置或web.config配置中的问题。这就是我需要你的帮助的地方。我将在下面解释我的设置。通常我在IIS 7中创建网站,而不是虚拟目录,但我的根目录中有一堆共享的JavaScript框架(现在未压缩),而且我有一堆应用程序共享这些文件。
我的理论是,我没有为网站本身进行配置。网站的路径是虚拟目录路径的上一级文件夹。有些东西告诉我我需要它,但我不记得它应该长什么样子。
你有什么想法吗?
注意,在Windows XP虚拟目录设置中,此设置完全正常。但我在Windows 7和Windows Server 2008上都遇到了此错误。
以下是网站错误信息:
图片描述: https://istack.dev59.com/4mOVx.webp 错误文本(用于搜索):
Server Error in '/' Application.

Configuration Error

Descriptionn: An error occurred during the processing of a configuration file required to service this request.  Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:

<compilation debug=true" targetFramework="4.0" />

网站链接:

http://localhost/app/index.aspx

我在应用程序池中更改了这3个设置(虚拟目录所在站点的应用程序池):

enter image description here

禁用“匿名身份验证”,启用“Windows身份验证”:

enter image description here

虚拟目录文件夹(网站子文件夹)中的web.config文件:

<?xml version="1.0" encoding="UTF-8"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <configSections>
    </configSections>

    <connectionStrings>
        <!-- Local Machine -->
        <add name="DATABASE" connectionString="Data Source=SERVERNAME\SQLEXPRESS;Initial Catalog=DATABASE-DEV;User ID=sa;Password=xxx" providerName="System.Data.SqlClient" />

    </connectionStrings>

    <!--<dataConfiguration defaultDatabase="DataAccessQuickStart">
    <providerMappings>
      <add databaseType="Devart.Data.Oracle.EnterpriseLibrary.OracleDatabase,Devart.Data.Oracle.EnterpriseLibrary" name="OracleX" />
    </providerMappings>
  </dataConfiguration>-->
    <!--<location path="." allowOverride="true">
  </location>-->
    <system.web>
        <compilation debug="true" targetFramework="4.0" />

        <authentication mode="Windows" />
        <authorization>
            <deny users = "?" />
        </authorization>

        <membership>
            <providers>
                <clear />
                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
            </providers>
        </membership>

        <profile>
            <providers>
                <clear />
                <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
            </providers>
        </profile>

        <roleManager enabled="false">
            <providers>
                <clear />
                <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
                <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
            </providers>
        </roleManager>

        <webServices>
            <protocols>
                <add name="HttpGet" />
                <add name="HttpPost" />
            </protocols>
        </webServices>

        <trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false" />


    </system.web>
    <appSettings>
    </appSettings>

    <!--<identity impersonate="true" />-->

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
</configuration>

1
你是否在IIS中将虚拟目录配置为“应用程序”了? - Stephen
1个回答

8

您需要在IIS中将虚拟目录配置为“应用程序”


1
有趣的是,这个问题获得了“值得关注的问题”徽章,但没有人点赞问题或答案。我点赞了你的答案,就这样。答案非常简单,但成千上万的人必须需要知道这个答案。 :-) - Entree

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接