"The attribute 'connectionStringName' is missing or empty." in Web.config - c#

I'm all of a sudden getting the following error with my Web.config file and I don't understand what it means:
Parser Error Message: The attribute 'connectionStringName' is missing or empty.
Line 24: <providers>
Line 25: <clear />
Line 26: <add name="SMDPortalMembershipProvider" type="SMDPortalMembershipProvider" />
Line 27: </providers>
Line 28: </membership>
Source File: c:\inetpub\wwwroot\web.config Line: 26
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272
Here's my config file:
<?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>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="UODOTNET, Version=2.2.5.7444,
Culture=neutral, PublicKeyToken=335F3FBD4BE82339"/>
<add assembly="System.Core, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="Default.aspx" timeout="2880" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<membership defaultProvider="SMDPortalMembershipProvider">
<providers>
<clear />
<add name="SMDPortalMembershipProvider" type="SMDPortalMembershipProvider" />
</providers>
</membership>
<customErrors mode="Off"/>
<sessionState cookieName="smd_portal_session" timeout="100"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
There is no error when I load the Default.aspx page, but as soon as my code calls upon the Membership class I'm getting the error.

Your membership provider's config section needs a connectionStringName attribute. Without that connectionStringName, it doesn't know what database to look for membership information in.
You need to add the name of one of your the connection strings in the connectionStrings section to the add tag on line 26.
The connectionStringName attribute is required in order for your Web.Config to be valid. You can't use the Membership class without it.

Related

configuring the .net adfs claims aware sample application

attempting to get the sampleapp (a claims aware web forms application) available from mircosoft https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachements/01/8598/00/00/03/64/54/88/SampApp%20and%20Rules.zip to run on our web server.
our adfs server is www.fedsvc3copa.beta.pa.gov
the sample app is hosted at application is https://costa.beta.pa.gov/
our federation metadata is https://www.fedsvc3copa.beta.pa.gov/federationmetadata/2007-06/FederationMetadata.xml
unfortunately believe I have something/s incorrect in my web config and struggling to find it. when I browse to https://costa.beta.pa.gov/ I receive
WIF10201: No valid key mapping found for securityToken:
'System.IdentityModel.Tokens.X509SecurityToken' and issuer:
'http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust'. 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.IdentityModel.Tokens.SecurityTokenValidationException:
WIF10201: No valid key mapping found for securityToken:
'System.IdentityModel.Tokens.X509SecurityToken' and issuer:
'http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust'.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityTokenValidationException: WIF10201: No valid key mapping
found for securityToken:
'System.IdentityModel.Tokens.X509SecurityToken' and issuer:
'http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust'.]
System.IdentityModel.Tokens.SamlSecurityTokenHandler.ValidateToken(SecurityToken
token) +1461
System.IdentityModel.Services.TokenReceiver.AuthenticateToken(SecurityToken
token, Boolean ensureBearerToken, String endpointUri) +135
System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase
request) +666
System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object
sender, EventArgs args) +467
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+139 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously) +88
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.7.3163.0
I have included my web config below if anyone notices anything that is incorrect.
<?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="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>
<location path="FederationMetadata">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<system.web>
<customErrors mode="Off"/>
<authorization>
<deny users="?" />
</authorization>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" requestValidationMode="4.5" />
<machineKey decryptionKey="5D497CFB20EB5927CB3FC44F65DBD3C6D6C366ACFCF20DC5" validationKey="80546F84BEDD8B38A995CCDD44E01C1794861685E605ECBFB5A231EAA7EAD9A99977312362EBDD2B9727F9357AF9A161F97AD49DD6E34E7CFC22D572BD4B90FD" />
</system.web>
<appSettings>
<add key="ida:FederationMetadataLocation" value="https://www.fedsvc3copa.beta.pa.gov/federationmetadata/2007-06/FederationMetadata.xml" />
<add key="ida:Issuer" value="https://www.fedsvc3copa.beta.pa.gov/adfs/ls/" />
<add key="ida:ProviderSelection" value="productionSTS" />
<add key="ida:EnforceIssuerValidation" value="false" />
</appSettings>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
<add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
</modules>
</system.webServer>
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="https://costa.beta.pa.gov/" />
</audienceUris>
<!--Commented by Identity and Access VS Package-->
<!--<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"><authority name="http://sts.costa.beta.pa.gov/adfs/services/trust"><keys><add thumbprint="I put my thumbprint here" /></keys><validIssuers><add name="sts.contoso.com" /></validIssuers></authority></issuerNameRegistry>-->
<!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.-->
<certificateValidation certificateValidationMode="None" />
<!--Commented by Identity and Access VS Package-->
<!--<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"><authority name="http://sts.costa.beta.pa.gov/adfs/services/trust"><keys><add thumbprint="?I put my thumbprint here" /></keys><validIssuers><add name="sts.contoso.com" /></validIssuers></authority></issuerNameRegistry>-->
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="https://www.fedsvc3copa.beta.pa.gov/adfs/services/trust">
<keys>
<add thumbprint="I put my thumbrint here " />
</keys>
<validIssuers>
<add name="https://www.fedsvc3copa.beta.pa.gov/adfs/services/trust" />
</validIssuers>
</authority>
</issuerNameRegistry>
<securityTokenHandlers>
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="true" />
<wsFederation passiveRedirectEnabled="true" issuer="https://www.fedsvc3copa.beta.pa.gov/adfs/ls/" realm="https://costa.beta.pa.gov/" requireHttps="true" />
</federationConfiguration>
</system.identityModel.services>
</configuration>
From memory, it's because that certificate that matches that thumbprint isn't in the certificate store - local computer.

Configuration Error in mvc5

I'm trying to add authentication and authorization to my website.I'm ding it with a help of tutorial. I added to web.config file and global.asax file following code as the tutorial does.But it gives me an error when i try to run the application.can anyone explain the error that i'v done..I created project by choosing "NO authentication" and I've installed Microsoft.AspNet.WebHelpers and Microsoft.AspNet.WebPages.Data packages.....I also added the WebMatrix.Data and WebMatrix.WebData referencesto the application
web.config file
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<membership defaultProvider="ePlannerProvider">
<providers>
<clear />
<add name="ePlannerProvider" type="WebMatrix.WebData.ePlannerProvider, WebMatrix.WebData" />
</providers>
</membership>
<roleManager enabled="true"/>
</system.web>
Global.asax file
WebSecurity.InitializeDatabaseConnection("EPlannerDatabaseEntities", "User", "Id", "Email", false);
Error message:
Parser Error Message: Could not load type 'WebMatrix.WebData.ePlannerProvider' from assembly 'WebMatrix.WebData'.
Source Error:
<providers>
<clear />
<add name="ePlannerProvider" type="WebMatrix.WebData.ePlannerProvider, WebMatrix.WebData" />
</providers>
</membership>
Error message says the type is not found.
Try to see version is right and use object browser to see if the class exists.
Also in reference, go to properties and set copy local as true.
Typically class names start with capital character

ASP.NET project throws HTTP Error 500.19 when moved to another computer

I copied a 3 layer ASP.NET project from a system running Visual Studio 2010 to my system which is also running Visual Studio 2010. When I right click and select view in browser on a file inside a folder located under the UI layer, I get the error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Attached is a screen shot of the error page
Below is the Web.config file inside the folder under UI layer
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow roles="user,admin"/>
<deny users="*"/>
<deny users="?"/>
</authorization>
</system.web>
<location path="fixdashboard.aspx">
<system.web>
<authorization>
<allow roles="user,client,admin"/>
<deny users="*"/>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="ws/__ws_eq.asmx">
<system.web>
<authorization>
<allow roles="user,client,admin"/>
<deny users="*"/>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Below is the root Web.config settings
<?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>
<connectionStrings>
<add name="dbcloudintegraConnectionStringb" connectionString="Data Source=PROGRAMOS-PC\INST1;Initial Catalog=dbcloudintegra;Persist Security Info=True;User ID=sa;Password=p#ssw0rd" providerName="System.Data.SqlClient" />
<add name="dbcloudintegraConnectionString" connectionString="Data Source=PROGRAMOS-PC\INST1;Initial Catalog=prom_temprary;Persist Security Info=True;User ID=sa;Password=p#ssw0rd" providerName="System.Data.SqlClient" />
</connectionStrings>
<location path="default.aspx">
<system.web>
<authorization>
<allow roles="user,admin"/>
<deny users="*"/>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="__upload.aspx">
<system.web>
<authorization>
<allow roles="user,admin"/>
<deny users="*"/>
<deny users="?"/>
</authorization>
</system.web>
</location>
<appSettings>
<add key="_cs" value="dbcloudintegraConnectionString"/>
<add key="fileuploads" value="D:\Users\Chibuzo\Documents\prog_fileuploads\"/>
<add key="errorlogs" value="D:\Users\Chibuzo\Documents\prog_errorlogs\"/>
<add key="enableLogOn" value="true"/>
<add key="enableRecaptcha" value="false"/>
<add key="domainAdminDays" value="5000"/>
<add key="domainPath" value="http://www.prominentetrade.com/"/>
<add key="recaptchaPublicKey" value="6LcZkvESAAAAAOWvWUtykUEoIGnU_qLiJlAvUN9e"/>
<add key="recaptchaPrivateKey" value="6LcZkvESAAAAAIBTKFXnqZHe_bqFLkwjtZfcgqoV"/>
</appSettings>
<system.web>
<sessionState cookieName="__CIP.SSID" timeout="20"/>
<customErrors mode="Off" defaultRedirect="~/500.aspx">
<error statusCode="404" redirect="~/404.aspx"/>
</customErrors>
<pages>
<controls>
<add tagPrefix="cloudintegra" src="~/controls/datepicker.ascx" tagName="datepicker"/>
<add tagPrefix="cloudintegra" src="~/controls/customersearch.ascx" tagName="customersearch"/>
<add tagPrefix="cloudintegra" src="~/controls/generalledgersearch.ascx" tagName="generalledgersearch"/>
<add tagPrefix="cloudintegra" src="~/controls/staffsearch.ascx" tagName="staffsearch"/>
<add tagPrefix="cloudintegra" src="~/controls/securitysearch.ascx" tagName="securitysearch"/>
<add tagPrefix="cloudintegra" src="~/controls/alert.ascx" tagName="alert"/>
<add tagPrefix="cloudintegra" src="~/controls/sidebar.ascx" tagName="sidebar"/>
<add tagPrefix="cloudintegra" src="~/controls/tools.ascx" tagName="tools"/>
<add tagPrefix="cloudintegra" src="~/controls/equitytrader.ascx" tagName="equitytrader"/>
<add tagPrefix="cloudintegra" src="~/controls/marketdata.ascx" tagName="marketdata"/>
</controls>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
<codeSubDirectories>
<add directoryName="VB"/>
</codeSubDirectories>
</compilation>
<authentication mode="Forms">
<forms name="__AUTH.PCI" loginUrl="~/login.aspx" slidingExpiration="true" timeout="20"/>
</authentication>
<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="dbcloudintegraConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="cloudintegra" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="dbcloudintegraConnectionString" applicationName="cloudintegra"/>
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear/>
<add connectionStringName="dbcloudintegraConnectionString" applicationName="cloudintegra" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
<add applicationName="cloudintegra" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
</providers>
</roleManager>
<webServices>
<protocols>
<!--<add name="HttpGet"/>-->
<add name="HttpPost"/>
</protocols>
</webServices>
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
<!--<httpModules>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules>-->
<httpRuntime requestValidationMode="2.0"/>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"></jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
<system.webServer>
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/octet-stream"/>
</staticContent>
</system.webServer>
<system.net>
</system.net>
</configuration>
How can I solve this problem?
EDIT:
From Andrew's answer, I found out that my IIS pool was set to .NET 2.0, so I changed it to 4.0. I still get internal Server Error, but it has changed.
Error Code 0x80070021
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Below is the screen shoot of the current error
Adding this as answer since its a bit longer to comment
<configuration> <configSections> <section name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup" /> </configSections> </configuration>
Try adding this to applicationHost.config
Also check your others paths are local in all config files
One reason this error can occur is if the Application was developed for .Net 4.0 but is running on an IIS Application pool set to .Net 3.5. Check the settings for your application pool and/or verify that .Net 4.0 is installed on the machine you moved the application to.
Also note, the HTTP error code 500.19 can have many different causes, and the IIS error code 0x80070032 is the more specific cause of the issue. There is a fairly lengthy discussion of error 0x80070032 at http://forums.iis.net/t/1166889.aspx
As a quick Workaround you could add the following to your root web.config:
<configuration>
<!-- add the missing section definitions as stated in the error message -->
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
...
But that's just a workaround. Usually these sections should be already declared in your machine.config. That file's located here: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
Edit:
It's surprising me, that adding these lines to your root web.config doesn't make any differences and you still get that error message...
But as Andrew already said in his answer this error can have many causes.
I faced a similar situation when I worked on a web application that was hosted as a separate application inside a site.
The structure was like the following:
theSite
├subDir1
├subDir2
└─seperateApplication
theSite had its own web.config with some special configscetions within and so on, and my seperateApplication had issues because being in a sub-directory of theSite led to inherting all those web.config-settings.
To cut a long story short, make sure that your application doesn't inherit some odd settings from another site which possibly removed those sections via <remove name="system.web.extensions" /> or something like that.
I had the same thing, but the fix was straightforward. I had to make two adjustments that had been saved in the solution and didn't match to the new location I moved it to. The adjustments were as follows:
1.) After transferring to the new local drive location I opened the solution in VS. In the top nav. clicked Tools -> Options -> See a popup. On the left of that "Option" popup, go to "Project and Solutions" -> "General" -> on the right, see 3 text input fields, update the "Projects location" by browsing to the folder where the solution placed when moved. (note, I did not update the two template locations) Save and Close
2.)(Optional) My solution had 2 projects, a project as a ui layer using the localhost and another as a business layer made as a class library; the ui layer being a web app, needed its virtual directory to be recreated. I did the following: Right click the project that was the ui layer --> click projects properties to see the properties tab -> On the left of that tab is a nav list-> Click "Web"-> On the right under the section titled "Server", click "Create Virtual Directory" to rebuild it. Save, exit
Then all was good and no errors and everything was running again
The only catch I had was in regards to saved breakpoints. I had to remove all saved breakpoints and re-establish.

LDAP Authentication in C# - Input string was not in a correct format

I'm trying to authenticate users through LDAP in C#. Each time I try to log in, I get the 'Input string was not in a correct format' error.
This is my connection string:
<connectionStrings>
<add name="MyConnectionString" connectionString="LDAP://123.193.111.22:389.local" />
</connectionStrings>
<system.web>
<roleManager enabled="true" />
<membership defaultProvider="MyMembershipProvider"><providers>
<add name="MyMembershipProvider"
connectionStringName="MyConnectionString"
type="System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionUsername="MyUsername"
connectionPassword="MyPassword"
connectionProtection="Secure"
enableSearchMethods="true" />
</providers>
</membership>
<trust level="Full" />
</system.web>
<authentication mode="Forms">
<forms name=".ADAuthCookie" loginUrl="~/Admin/Login"
timeout="450" slidingExpiration="false" protection="All"/>
</authentication>
The error seems to be at type="System.Web.Security.ActiveDirectoryMembershipProvider. Any suggestions would be greatly appreciated. Thanks!
I've managed to figure it out. Had to rework the membership provider code and now I'm able to authenticate users.

ASP.Net Linq to Entity: The underlying provider failed on Open

I seem to be having a recurring problem. I get it all working and then this happens again a few days later. I havn't done anything to touch the entity framework or the database that is now failing. The instantiation of the Entity edmx is working but I get the following message when trying to execute a query to the database. The way I've solved it is by deleting the databases and clearing out the SQL MGMT Studio and adding them in again and refressing the edmx file.
I have 2 project: DataLayer where my entity framework definition exists, Business Logic and UI. I noticed there are some differences between the web.config between my DataLayer and the UI and don't know if that's a problem. The database was added to the App_Data folder in the DataLayer. The solution keeps adding a copy of the database to the AppData folder in the UI and addes a numberic extension to the filename in the Server Explorer( In the BL the filename is FCGuide.mdf, in the UI is was anmed FCGuide.mdf0 -- don't understand that).
Today I have deleted the database from the project and from the SQL SErver Management Studio and then tried adding it in again without a resolution. I have provided the web.config but not sure what else is needed to help with the troubleshooting. Thanks in advance.
WEB.CONFIG file from the UI:
<?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>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
<system.webServer>
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<system.web>
<authorization>
<allow roles="ADMIN" />
<allow roles="MEMBER" />
<allow roles="GUEST" />
<allow roles="RESTAURANT" />
<allow users="admin" />
<allow roles="MEMBER" />
<allow roles="GUEST" />
<allow roles="GUEST" />
<allow roles="ADMIN" />
<allow users="admin" />
</authorization>
<roleManager enabled="true" />
<authentication mode="Forms" />
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<connectionStrings>
<add name="FCGuideEntities" connectionString="metadata=res://*/FCGuide.csdl|res://*/FCGuide.ssdl|res://*/FCGuide.msl;provider=System.Data.SqlClient;provider connection string="data source=.;attachdbfilename=|DataDirectory|\FCGuide.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
Web Config file from the DataLayer:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<connectionStrings>
<add name="FCGuideEntities" connectionString="metadata=res://*/FCGuide.csdl|res://*/FCGuide.ssdl|res://*/FCGuide.msl;provider=System.Data.SqlClient;provider connection string="data source=.;attachdbfilename=|DataDirectory|\FCGuide.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
"The underlying provider failed on Open": this means the connection string didn't work to allow ADO.NET to open the database.
So the provider connection string:
data source=.;attachdbfilename=|DataDirectory|\FCGuide.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework
needs some work. If you create a test page that uses SQL Connection on that string can you open and perform a simple query?
(Ie. strip things down to as few moving parts as possible).

Categories