2017-05-31 1 views
0

In meiner ASP.NET (4.5) Forms-Anwendung versuche ich Authentifizierung und Autorisierung zu aktivieren und nicht in der Lage, es zum Laufen zu bringen. Ich habe Anweisungen gefunden, um das Folgende zur Datei Web.config hinzuzufügen, aber alle Anfragen an Seiten erhalten den Fehler HTTP Error 500.19 - Interner Serverfehler Die angeforderte Seite kann nicht aufgerufen werden, da die zugehörigen Konfigurationsdaten für die Seite ungültig sind.asp.net 4.5 aktivieren Formulare Authentifizierung Fehler

Auch in meiner Datei Web.config gibt es eine Fehlermeldung „Das Element‚system.web‘hat ungültiges Kindelement‚Formen‘.

Bei Visual Studio aus der Box die Authentifizierungscodes erzeugt, I .? dachte, das wäre etwas, das einfach zu ermöglichen sein sollte Wie kann ich dieses Problem beheben

fand ich bei online Informationen zu meinem Web.config hinzufügen Authentifizierung und Autorisierung zu aktivieren:

<system.web> 
    <authentication mode="Forms"> 
    <forms loginUrl="~/Account/Login" timeout="30" /> 
    </authentication> 
</system.web> 

<system.webServer> 
    <security> 
    <authentication> 
     <anonymousAuthentication enabled="true" /> 
    </authentication> 
    </security> 
<system.webServer> 

Hier ist mein Web.config ohne die Verbindungszeichenfolgen ele Anweisungen:

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    https://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 

    <system.web> 
    <authentication mode="Forms" /> 
    <forms loginUrl="~/Account/Login" timeout="30" /> 
    <compilation debug="true" targetFramework="4.5.2" /> 
    <httpRuntime targetFramework="4.5.2" /> 
    <pages> 
     <namespaces> 
     <add namespace="System.Web.Optimization" /> 
     <add namespace="Microsoft.AspNet.Identity" /> 
     </namespaces> 
     <controls> 
     <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" /> 
     </controls> 
    </pages> 
    <membership> 
     <providers> 
     <!-- 
      ASP.NET Membership is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template 
     --> 
     <clear /> 
     </providers> 
    </membership> 
    <profile> 
     <providers> 
     <!-- 
      ASP.NET Membership Profile is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template 
     --> 
     <clear /> 
     </providers> 
    </profile> 
    <roleManager> 
     <!-- 
      ASP.NET Membership Role is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template 
     --> 
     <providers> 
     <clear /> 
     </providers> 
    </roleManager> 
    <!-- 
      If you are deploying to a cloud environment that has multiple web server instances, 
      you should change session state mode from "InProc" to "Custom". In addition, 
      change the connection string named "DefaultConnection" to connect to an instance 
      of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express. 
     --> 
    <sessionState mode="InProc" customProvider="DefaultSessionProvider"> 
     <providers> 
     <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /> 
     </providers> 
    </sessionState> 
    <httpModules> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
    </httpModules> 

    </system.web> 
    <system.webServer> 
    <security> 
     <authentication> 
     <anonymousAuthentication enabled="true" /> 
     </authentication> 
    </security> 
    <modules> 
     <remove name="FormsAuthentication" /> 
     <remove name="ApplicationInsightsWebTracking" /> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> 
    </modules> 
    <validation validateIntegratedModeConfiguration="false" /> 
    </system.webServer> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> 
     <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" /> 
     <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
    </compilers> 
    </system.codedom> 
</configuration> 
+0

platzieren Sie nur 1 Config-Datei in Ihrem Stammordner? schaue hier https://stackoverflow.com/questions/1866229/forms-authentication-web-config-set-up – MethodMan

+0

Warum hat deine LoginUrl keine Erweiterung? Sollte es nicht so lauten: ? – Ian

Antwort

1

Die Datei web.config ist falsch. Sie haben dies:

<authentication mode="Forms" /> 
<forms loginUrl="~/Account/Login" timeout="30" /> 

Und es sollte sein:

<authentication mode="Forms" > 
    <forms loginUrl="~/Account/Login" timeout="30" /> 
</authentication> 
+0

Danke - Ich habe die Korrektur gemacht, aber ich bekomme jetzt diesen Fehler: HTTP Error 500.19 - Interner Server Fehler Die angeforderte Seite kann nicht zugegriffen werden, da die zugehörigen Konfigurationsdaten für die Seite ungültig sind. Dies zeigt auf: Config Quelle: 78: 79: 80: ikask

+0

@ikask welche? – hardkoded

+0

Dieser: 79: ikask

Verwandte Themen