Hello I have a problem with my connection string below:
<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="ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors defaultRedirect="~/error.aspx" mode="RemoteOnly"/>
<authentication mode="Forms">
<forms loginUrl="~/login.aspx" />
</authentication>
<authorization>
<allow users="*" />
</authorization>
<roleManager enabled="true" />
<compilation debug="true" />
<membership>
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
</system.web>
<location path="~/securepage.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Can anyone let me know were the proble is coming front? I don't know if the problem is coming from
add name="ApplicationServices".
I will appreciate ur help
You're referencing connectionStringName="LocalSqlServer" which doesn't exist. The two connection strings you have registered are ApplicationServices and ConnectionString.
Rename your second connection string entry to:
<add name="LocalSqlServer" ...
Related
**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.
I'm integrating security into an existing asp classic website. and I'd like to keep the anonymous users able to still access the site until I'm ready to flip the switch. Shouldn't setting allow users="*" let everyone in and not redirect? Right now it's redirecting all pages until you authenticate.
<configuration>
<connectionStrings>
<add name="foConnectionString" connectionString="Data Source=;Initial Catalog=fo;Persist Security Info=True;User ID=foSecurity;Password=" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="foSecurityConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/foSecurity"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="foSecurityConnectionString" applicationName="/foSecurity"/>
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="foSecurityConnectionString" applicationName="/foSecurity"
name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/foSecurity" name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="index.asp" />
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I have a application that connects to a remote sql server. I am able to create users and they are stored in the DB. Then I can go to the login page and login. But after a while, I am unable to log in and it just sits at the login page. The user is still in the DB
Help?
<configuration>
<connectionStrings>
<add name="LoginSQL" providerName="System.Data.SqlClient"
connectionString="Data Source=xx.xx.xx.xx;Initial Catalog=xxxx;UID=xxxxx;pwd=xxxx;"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms name="Login" loginUrl="Default.aspx" protection="All" timeout="20"/>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<membership defaultProvider="MySqlLoginProvider">
<providers>
<add name="MySqlLoginProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LoginSQL" applicationName="Login" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" passwordAttemptWindow="30" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager defaultProvider="MyRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPRoles" cookiePath="/" cookieTimeout="60" cookieSlidingExpiration="true" cookieProtection="All">
<providers>
<add name="MyRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="LoginSQL" applicationName="Login"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
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.
I have created a user by using CreateUserWizard - control.
My web.config file is as follows:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="ConnString1" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=IceWebPortal_SQL2K5;user=sa;password=;integrated security=true;" providerName="System.Data.SqlClient"/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnet_membership_test;Integrated Security=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.
-->
<compilation debug="true" />
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms
name="CookieDemo"
loginUrl="Default.aspx"
protection="All"
timeout="30"
path="/"
/>
</authentication>
<!--<authorization>
<deny users="?"/>
</authorization>-->
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*"></allow>
</authorization>
</system.web>
</location>
</configuration>
I am finding that, FormsAuthentication.Authenticate(username, password); is always returning false.
string username = this.usernameTextBox.Text;
string password = this.passwordTextBox.Text;
bool success = FormsAuthentication.Authenticate(username, password);
if (success)
{
}
What can be the problem?
You need to add e.g. a MembershipProvider configuration or add users directly to web.config (which is probably not a good idea)-
Example:
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="/" />
</providers>
</membership>