c# - <认证模式 ="forms"> Godaddy 主机配置错误

标签 c# asp.net iis

我在 Godaddy Hosting 中部署了一个 Web 应用程序,还创建了一个虚拟目录。但是当我尝试通过 URL 访问应用程序时,出现以下错误


`Server Error in '/' Application.

Configuration Error

Description: 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.

来源错误:

</assemblies>
</compilation> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" />

</authentication>

我试着用谷歌搜索了一下,几乎大部分答案都与虚拟目录有关。我在这里附上了我的 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=152368
  -->
`<configuration>`
   `<connectionStrings>
    <add name="ApplicationServices" connectionString="data            source=.\SQLEXPRESS;Integrated     Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"     providerName="System.Data.SqlClient" />
    <add name="fbpmProjectDetailsEntities"        connectionString="metadata=res://*/Models.ProjectDetail.csdl|res://*/Models.ProjectDetail.ss    dl|res://*/Models.ProjectDetail.msl;provider=System.Data.SqlClient;provider connection     string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\fbpm.mdf;integrated     security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;"     providerName="System.Data.EntityClient" />
    <add name="fbpmUserEntities"      connectionString="metadata=res://*/Models.UserModel.csdl|res://*/Models.UserModel.ssdl|res:/    /*/Models.UserModel.msl;provider=System.Data.SqlClient;provider connection      string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\fbpm.mdf;integrated     security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;"     providerName="System.Data.EntityClient" />
    <add name="fbpmUserPaySchedEntities"      connectionString="metadata=res://*/Models.UserPaymentSchedule.csdl|res://*/Models.UserPaymentSchedule.ssdl|res://*/Models.UserPaymentSchedule.msl;provider=System.Data.SqlClient;provide    r connection string=&quot;data     source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\fbpm.mdf;integrated security=True;user     instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;"     providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="1.0.0.0" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral,     PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral,   PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral,  PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
    </authentication>
    <membership>
  <providers>
    <clear />
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="3" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" applicationName="/" />
  </providers>
</membership>
<profile>
  <providers>
    <clear />
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</profile>
<roleManager enabled="true">
  <providers>
    <clear />
    <add connectionStringName="ApplicationServices" applicationName="/"
      name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
    <add applicationName="/" name="AspNetWindowsTokenRoleProvider"
      type="System.Web.Security.WindowsTokenRoleProvider" />
  </providers>
</roleManager>
<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>
<customErrors mode="Off"/>
  </system.web>
  <system.webServer>
      <modules runAllManagedModulesForAllRequests="false">
          <remove name="FormsAuthenticationModule" />
          <add name="FormsAuthenticationModule"     type="System.Web.Security.FormsAuthenticationModule" />
          <remove name="UrlAuthorization" />
          <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"     />
      </modules>
    <validation validateIntegratedModeConfiguration="false" />
   <!--<modules runAllManagedModulesForAllRequests="true" />-->
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
     </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>`

请帮助我确定问题。

谢谢,森蒂

最佳答案

我猜真正的问题是认证之前的元素,也就是编译。这表明 targetFramework 属性实际上可能是罪魁祸首,这本身表明您可能没有将 IIS 应用程序池配置为使用 .NET v4,而是 v2.0

关于c# - <认证模式 ="forms"> Godaddy 主机配置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16727612/

相关文章:

javascript - HTML 到 JS 数据表 : Still show a removed row after sorting or page size change?

IIS压缩

c# - 将 Common.Logging 与 Asp.net MVC 和 CaSTLe Windsor 结合使用

c# - 当字符串为空时,C# Automapper 如何将字段设置为 null

asp.net - 为什么 ASP.NET 跟踪有时会起作用?

asp.net - 用户定义的 CSS/样式

c# - 无法使用 C# 以编程方式访问 iis 远程服务器

.net - 应用程序暂停IIS应用程序池.Net 4.5.1

c# - 现有文件名和创建唯一文件名的问题

c# - 使用System.Net.Socket,我们如何知道远程套接字何时关闭?