2015-05-20 2 views
1

ASP.NET WebForms и я делаю проверку подлинности для пользователей, но я получаю эту ошибку в файле web.config:Ошибка в Web Config в ASP.NET

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: sections are allowed only within sections.

Source Error:

Line 38: Line 39: Line 40: Line 41: Line 42:

Source File: C:\Users\dunja\Desktop\webapp1\web.config
Line: 40

Вот содержание Web.Config файла:

<?xml version="1.0"?> 

<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > 
     <section name="webapp1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 
    <connectionStrings> 
    <add name="constr" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=Gy;Integrated Security=SSPI;"/> 
    </connectionStrings> 
    <!-- 
    For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367. 

    The following attributes can be set on the <httpRuntime> tag. 
     <system.Web> 
     <httpRuntime targetFramework="4.5" /> 
     </system.Web> 
    --> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5"/> 
    <httpRuntime/> 
    <pages controlRenderingCompatibilityVersion="4.0"> 
     <namespaces> 
     <add namespace="System.Web.Optimization"/> 
     </namespaces> 
     <controls> 
     <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/> 
     </controls> 
    </pages> 
    <authentication mode="Forms"> 
     <forms defaultUrl="~/User/User.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880"></forms> 
    </authentication> 

    <location path="Admin"> 

     <authorization> 
     <allow roles="admin"/> 
     <deny users="*"/> 
     </authorization> 

    </location> 
    </system.web> 
</configuration> 

Спасибо всем!

ответ

0

Места вашего расположения тега непосредственно перед закрытием конфигурации тега, так же, как этого

<location path="Admin"> 
<system.web> 
    <authorization> 
    <allow roles="admin"/> 
    <deny users="*"/> 
    </authorization> 
</system.web> 

Надеется, что это помогает ... !

1

Ваш раздел местоположения должен быть указан за пределами тега <system.web> и внутри раздела <location> вам необходимо добавить <system.web> теги. Пожалуйста, обратитесь измененным конфигурационный файл ниже

<?xml version="1.0"?> 

<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > 
     <section name="webapp1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 
    <connectionStrings> 
    <add name="constr" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=Gy;Integrated Security=SSPI;"/> 
    </connectionStrings> 
    <!-- 
    For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367. 

    The following attributes can be set on the <httpRuntime> tag. 
     <system.Web> 
     <httpRuntime targetFramework="4.5" /> 
     </system.Web> 
    --> 
<location path="Admin"> 
    <system.Web> 
     <authorization> 
     <allow roles="admin"/> 
     <deny users="*"/> 
     </authorization> 
    </system.Web> 
</location> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5"/> 
    <httpRuntime/> 
    <pages controlRenderingCompatibilityVersion="4.0"> 
     <namespaces> 
     <add namespace="System.Web.Optimization"/> 
     </namespaces> 
     <controls> 
     <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/> 
     </controls> 
    </pages> 
    <authentication mode="Forms"> 
     <forms defaultUrl="~/User/User.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880"></forms> 
    </authentication> 


    </system.web> 
</configuration> 
Смежные вопросы