i'm getting this "Unrecognized configuration section system.web/configuration when i set my admin,staff and user authentication .please help me with this.by here i provide the web.config code
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="ASPNETDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Se7en\Desktop\Personal\VIVA\1\App_Data\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<configuration>
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx">
<credentials passwordFormat="Clear">
<user name="admin" password="password"/>
</credentials>
</forms>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true"/>
</system.web>
<location path="adminstrator">
<system.web>
<authorization>
<allow users="adminstrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="staff">
<system.web>
<authorization>
<allow users="staff"/>
<deny users="*"/>
<allow roles="adminstrator" />
</authorization>
</system.web>
</location>
<location path="user">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
<!--
<authentication mode="Forms"/>
-->
<roleManager enabled="true"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
</configuration>
Try this:
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="ASPNETDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Se7en\Desktop\Personal\VIVA\1\App_Data\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<location path="adminstrator">
<system.web>
<authorization>
<allow users="adminstrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="staff">
<system.web>
<authorization>
<allow users="staff"/>
<deny users="*"/>
<allow roles="adminstrator" />
</authorization>
</system.web>
</location>
<location path="user">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<system.web>
<roleManager enabled="true"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="Login.aspx">
<credentials passwordFormat="Clear">
<user name="admin" password="password"/>
</credentials>
</forms>
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
Related
this is my configuration for elmah in web.config
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<allow roles="Dev" />
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH"
verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" />
</handlers>
</system.webServer>
But how do tell that I'm a Dev ? I'm using Session for cookies but I don't know how can i tell that i'm an admin or user
**I have error in local host**
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="conversationDB" providerName="System.Data.SqlClient" connectionString="Data Source=Mojtaba;Initial Catalog=conversation;Integrated Security=True"/>
</connectionStrings>
<system.web>
please resolve this error for me thank you
<roleManager>
<providers>
<add connectionStringName="DefaultConnection" applicationName="/"
name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</roleManager>
<membership defaultProvider="Mymembershipprovider">
<providers>
<add name="Mymembershipprovider" type="WebMatrix.WebData.MyRoleProvider, WebMatrix.WebData"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="MyRoleProvider">
<providers>
<clear/>
<add name="MyRoleProvider" type="SecurityInASPNET.MyRoleProvider"/>
</providers>
</roleManager>
<authentication mode="Forms">
<forms name=".RememberMe" loginUrl="~/result.aspx" timeout="130000" slidingExpiration="true" defaultUrl="~/score/Mojtaba.aspx">
</forms>
</authentication>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<!--WebForms UnobtrusiveValidationModeخطای صفحهی لاگین-->
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<!--WebForms UnobtrusiveValidationModeخطای صفحهی لاگین-->
<location path="score_Mojtaba.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
You are not supposed to have two roleManager section, remove the useless one.
Guys I am trying to use MSCaptcha in asp.net website. It is working perfectly but as soon as I add Forms authentication in web.config, the captcha image is not displayed.
Web.config before authentication (Captcha image shows up)
<system.web>
<httpRuntime targetFramework="4.5" />
<authorization>
<allow users="*" />
</authorization>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha" />
</httpHandlers>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="MSCaptcha.captchaImageHandler" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha" resourceType="Unspecified" />
</handlers>
Web.Config after forms authentication is added (Captcha image doesn't load)
<system.web>
<httpRuntime targetFramework="4.5" />
<authorization>
<deny users="?" />
<allow users="*" />
<allow users="GET" />
</authorization>
<authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="Default2.aspx"
protection="All" path="/" timeout="30" />
</authentication>
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha" />
</httpHandlers>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="MSCaptcha.captchaImageHandler" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha" resourceType="Unspecified" />
</handlers>
Why is forms authentication causing issues for captcha? what should I do?
P.S this web-config file is not complete so it might look confusing.
You need to add LOCATION in your web.config :
<location path="CaptchaImage.axd">
<system.web>
<authorization>
<allow users="*">
</allow>
</authorization>
</system.web>
</location>
I'm hosting my site on a commercial server IIS6 - i'm trying to move it to one of their IIS7 boxes. (code works fine on IIS6) I'm getting 500.19 error stating the web.config file is the error? (same file on both servers) I have the IIS7 box set to classic mode. Hosting company is no help! - when I view my config file I do see "XML Error : mismatched tag" but why? it;s the last line </configuration> and matches the 2nd line <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
here is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="DefaultConnectionString" value="AccessMembershipProvider" />
<add key="EmailFrom" value="webmaster#domain.com"/>
<add key="EmailTo" value="xyz#hotmail.com"/>
<add key="BlindEmail" value="xyz#hotmail.com"/>
<add key="TechTrainingConn" value="Provider=Microsoft.Jet.OleDb.4.0; Data Source=e:\App_Data\Tech_Training.mdb"/>
<add key="TechTraining" value="~/App_Data/Training.mdb" />
</appSettings>
<connectionStrings>
<add name="OdbcServices" connectionString="Driver={Microsoft Access Driver (*.mdb)};Dbq=e:\App_Data\Training.mdb;" />
<add name="OBDCConnectionString" connectionString="Dsn=MS Access Database;dbq=e:\App_Data\Tech_Training.mdb;defaultdir=e:\App_Data;driverid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5;uid=admin"
providerName="System.Data.Odbc" />
<add name="TTSite" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\App_Data\Tech_Training.mdb;User Id=admin;Password=;" providerName="System.Data.OleDb" />
<add name="accessConnectionString" connectionString="~/App_Data/Tech_Training.mdb" />
<system.net>
<mailSettings>
<smtp deliveryMethod="network" from="webmaster#domain.com">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
<authentication mode="Forms" />
<membership defaultProvider="AccessMembershipProvider"
userIsOnlineTimeWindow="20">
<providers>
<add name="AccessMembershipProvider"
type="AccessMembershipProvider"
enablePasswordReset="true"
enablePasswordRetrieval="true"
requiresQuestionAndAnswer="true"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\App_Data\Tech_Training.mdb;Persist Security Info=False"
/>
</providers>
</membership>
<roleManager defaultProvider="OdbcRoleProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="All" >
<providers>
<clear />
<add name="OdbcRoleProvider"
type="Samples.AspNet.Roles.OdbcRoleProvider"
connectionStringName="OdbcServices"
applicationName="SampleApplication"
writeExceptionsToEventLog="false" />
</providers>
</roleManager>
</system.web>
<location path="XYZ">
<system.web>
<authorization>
<allow roles="Admin" />
<allow roles="Chiefs" />
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
Your issue isn't the last line, you're missing the closing tag on the connectionstrings element.
Hello everyone can someone help me with my web.config file? I am having error. I just want you guys to look at it and if there are errors someone that needs correction. Thank you all:
This is the error message:
Warning 1 The 'targetFramework' attribute is not declared. G:\display images in gridview\Web.config 17 62 Miscellaneous Files
Message 2 Could not find schema information for the element 'modules'. G:\display images in gridview\Web.config 51 7 Miscellaneous Files
Message 3 Could not find schema information for the attribute 'runAllManagedModulesForAllRequests'. G:\display images in gridview\Web.config 51 15 Miscellaneous Files
Error 4 The 'configuration' start tag on line 10 does not match the end tag of 'system.web'. Line 101, position 4. (C:\Users\Collins\Documents\Visual Studio 2005\WebSites\living to please god world\web.config line 101)
Here is the Web.config file:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/"/>
</providers>
</profile>
<authentication mode="Forms">
<forms loginUrl="login.aspx" defaultUrl="Default.aspx"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<location path="PhotoAdmin">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<system.net>
<mailSettings>
<smtp from="some#example.com">
<network host="relay-hosting.example.net" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>
</configuration>
Well there are several things that are messed up.
The targetFramework attribute must be specified if the application pool that you are using is set up to use .Net Framework 4. If this is the case then you should have the following section under system.web:
<compilation debug="true" targetFramework="4.0" />
The system.web section is closed too earlier. The sections 'pages', 'membership', 'profile', 'authentication' and 'authorization' must be subsections of system.web.