weird asp.net error

jazzIIIlove
jazzIIIlove used Ask the Experts™
on
Hi;

I have a .NET web application in which I end up with the following error:

Parser Error Message: The connection name 'ApplicationServices' was not found in the applications configuration or the connection string is empty.

Source Error: 


Line 57: 			<providers>
Line 58: 				<clear/>
Line 59: 				<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
Line 60: 			</providers>
Line 61: 		</membership>

Open in new window


Now the thing is that i have also a database in the application but i am not using the database for this type of login.
I "manually" add the following lines and the problem appeared:

<asp:login id="Login2" runat="server" style="width: 100%;">
    <layouttemplate>
        <div class="box">
            <div class="content">
                <h1>
                    Authentication Required</h1>
                <asp:textbox class="field" placeholder="uss" id="UserName" runat="server"></asp:textbox>
                <asp:requiredfieldvalidator id="UserNameRequired" runat="server" controltovalidate="UserName" errormessage="User Name is required." tooltip="User Name is required." validationgroup="Login1">*</asp:requiredfieldvalidator>
                <br>
                <asp:textbox class="field" placeholder="paa" id="Password" runat="server" textmode="Password"></asp:textbox>
                <asp:requiredfieldvalidator id="PasswordRequired" runat="server" controltovalidate="Password" errormessage="Password is required." tooltip="Password is required." validationgroup="Login1">*</asp:requiredfieldvalidator>
                <br>
                <asp:button class="btn" id="Submit" runat="server" commandname="Login" text="Log In" validationgroup="Login1" onclick="Submit_Click" ></asp:button>
                <br>
                <asp:literal id="FailureText" runat="server" enableviewstate="False"></asp:literal></div>
        </div>
    </layouttemplate>

Open in new window


Note that the username and password that is inputted by user above is "NOT" stored in database. I merely check the inputs against hard coded values.

Can you help me why I receive the above error?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Naitik GamitSoftware Developer
Top Expert 2015
Commented:
problem is the membership section in web.config. The ASP.NET configuration tool uses "ApplicationServices" by default. If you change it to use another name connection string, it should work.

Change connectionStringName name in web.config


<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="Changename" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
Hi;

Thanks for the information. I changed the connection string name to a connection string that is defined before. Note that as underlined, I don't use the logic of connection string for logging in, yet I changed it as follows:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
	</configSections>
	<appSettings>
		<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
		<add key="log4net.Internal.Info" value="true"/>
	</appSettings>
	<log4net debug="true">
		<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
			<file value="C:\\myloig.txt"/>
			<appendToFile value="true"/>
			<rollingStyle value="Size"/>
			<maxSizeRollBackups value="10"/>
			<maximumFileSize value="10MB"/>
			<staticLogFileName value="true"/>
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%d %-4timestamp %-5level %logger - %message%newline"/>
			</layout>
			<!--layout type="log4net.Layout.PatternLayout"-->
			<!--conversionPattern value="%d %5rms %c %-5p %M - %m%n" /-->
			<!--conversionPattern value="%d %5rms %c %M - %m%n"/-->
			<!--/layout-->
		</appender>
		<root>
			<level value="DEBUG"/>
			<appender-ref ref="RollingLogFileAppender"/>
		</root>
	</log4net>
	<connectionStrings>
		<!--<add name="FolderPath" ="~/uploads"/>-->
		<add name="ConnectionString" connectionString="server=(local);Initial Catalog=testdb;Integrated Security=False;User Id=sa;Password=testdb;MultipleActiveResultSets=True"/>

	</connectionStrings>
	<system.web>
		<compilation debug="true" targetFramework="4.0">
		</compilation>
		<authentication mode="Forms">
			<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
		</authentication>
		<membership>
			<providers>
				<clear/>
				<!-- I changed here-->
				<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
			</providers>
		</membership>
		<profile>
			<providers>
				<clear/>
				<!-- I changed here-->
				<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ConnectionString" applicationName="/"/>
			</providers>
			
		</profile>
		<roleManager enabled="false">
			<providers>
				<clear/>
				<!-- I changed here-->
				<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ConnectionString" applicationName="/"/>
				<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
			</providers>
		</roleManager>
		<httpRuntime maxRequestLength="100000" />
		<customErrors mode="Off" defaultRedirect="~/GeneralError.aspx">
		</customErrors>
		<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
	<system.webServer>
		<modules runAllManagedModulesForAllRequests="true">
		</modules>
		<defaultDocument>
			<files>
				<clear/>
				<add value="Home.aspx"/>
				<add value="Default.aspx"/>
				<!--<add value="index.html" />-->
			</files>
		</defaultDocument>
		<directoryBrowse enabled="true"/>
		<handlers>
			<add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.captchaImageHandler, MSCaptcha"/>
		</handlers>
	</system.webServer>
</configuration>

Open in new window


and I end up with the following error, and registering aspnet_regsql.exe didn't help

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

Please help.

Best regards.
Naitik GamitSoftware Developer
Top Expert 2015

Commented:
Try to, restarting management studio would resolve the issue in most of the cases.

please provide your code behind code.
Hi;

The solution seems to be this, http://stackoverflow.com/questions/2165908/could-not-find-stored-procedure-dbo-aspnet-checkschemaversion

aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName
Well running on cmd seems better than invoking the SQL UI

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial