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

问题描述 投票:3回答:3

我一直试图从我的计算机访问我的合作伙伴的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行)

asp.net iis web-applications
3个回答
4
投票

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

要解决这个问题,你必须做到:

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

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>

0
投票

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

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

必须移动到Startup.Configuration,此配置后Owin的Autofac配置发生。

© www.soinside.com 2019 - 2024. All rights reserved.