如何解决'/'应用程序中的服务器错误。

时间:2013-05-22 02:51:44

标签: asp.net iis web-applications

我一直在尝试从我的计算机访问我的合作伙伴的Web应用程序,但这个问题一直在显示。我试图将Web应用程序转换为IIS中的应用程序,但问题仍然存在。

配置错误 描述:处理为此请求提供服务所需的配置文件时发生错误。请查看下面的具体错误详细信息并相应地修改配置文件。

分析程序错误消息:在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的。此错误可能是由于虚拟目录未在IIS中配置为应用程序。

来源错误:

Line 17:                <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 18:                <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
Line 19:        <authentication mode="Forms">
Line 20:            <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
Line 21:        </authentication>

源文件:C:\ inetpub \ wwwroot \ fas \ fas \ web.config行:19

显示其他配置错误:

在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的。此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的。 (C:\ inetpub \ wwwroot \ fas \ fas \ web.config第22行) 在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的。此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的。 (C:\ inetpub \ wwwroot \ fas \ fas \ web.config第28行) 在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的。此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的。 (C:\ inetpub \ wwwroot \ fas \ fas \ web.config第34行)

3 个答案:

答案 0 :(得分:4)

问题发生的原因是您在应用程序的子目录中有另一个web.config文件,并且它具有authentication元素。 authentication元素只能出现在根web.config中。请参阅元素文档here。在元素信息部分下,声明可配置位置 Machine.config,根级Web.config,应用级Web.config

要解决此问题,您必须执行以下任一操作:

  • 卸载子web.config,并将其保留在根目录上。
  • 或者,如果子web.config对您的应用程序至关重要,请从中删除整个authentication元素。您可以在根级别web.config中仅配置authentication一次。

答案 1 :(得分:1)

您的web.config不正确。

你有这样的事情:

<configuration>
    <system.web>
        <compilation>
            <assemblies>
               <add assembly="System.Design, ..."/>
               <!-- many  more -->
               <add assembly="System.Design, ..."/>
        <authentication mode="Forms">
            <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
        </authentication>

您需要一些结束标记:

            <assemblies>
               <add assembly="System.Design, ..."/>
               <!-- many  more -->
               <add assembly="System.Design, ..."/>
            </assemblies> <!-- You need this -->
        </compilation>    <!-- and this -->
        <authentication mode="Forms">
            <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
        </authentication>

答案 2 :(得分:0)

在我的情况下,这是Owin的错误配置

FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

必须移至Startup.Configuration,此配置后,Owin的Autofac配置才会发生。