I am creating an ASP.NET webage that retrieve and insert data inside CRM 2011.
Everything was going fine, the page was being deployed to the server and it was ready to test.
Suddenly a new change come out, and after I deleted the files in the server and republished the project (I know it is not needed, but still..) I could not access the website anymore.
All I get is 500- Internal server error
There is a problem with the resource you are looking for, and it cannot be displayed.
I tried turning on the debug function with debug="True" on the page header, I set
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.5"/>
On the web.config file, and I also tried adding
<httpErrors errorMode="Detailed" />
but none of them helped having a better error message.
My web.config file is:
<?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>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ASP-20130619150943;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ASP-20130619150943.mdf"/>
</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>
<customErrors mode="Off"/>
<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 loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/"/>
</authentication>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
</providers>
</roleManager>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"/>
</providers>
</sessionState>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246"/>
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246"/>
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
</entityFramework>
<appSettings>
<add key="CRMUserName" value="xxxx" />
<add key="CrmUserPassword" value="yyyy" />
<add key="OrganizationUri" value="https://uuuuuu/XRMServices/2011/Organization.svc" />
<add key="HomeRealmUri" value="" />
</appSettings>
</configuration>
I get an error message when I run the page.
The error message is:
An error occurred when verifying security for the message
System.ServiceModel.FaultException: An error occurred when verifying security for the message.
The section where the error fires is:
RetrieveAttributeRequest retrieveFreightTerm = new RetrieveAttributeRequest
{
EntityLogicalName = "account",
LogicalName = "address1_freighttermscode",
RetrieveAsIfPublished = true
};
Any ideas?
I opened the website from the server running IIS and I could see a detailed error page, with all the information I needed
Many times it happens after editing the web.config file, we leave some tag not properly closed or to say not well formed. This also leads to 500 Internal server error.
To make sure your web.config atleast passes this check, open it in Internet Explorer. In case any tags are missed out, the IE will show you the corresponding error.
Related
Does anyone have some good direction on how to debug a .NET Login control that always returns false?
I am developing a simple .NET application that authenticates against Active Directory. I am following the example given at this url: http://geekswithblogs.net/frankw/archive/2008/05/18/forms-authentication-with-active-directory-in-asp.net-2.0.aspx
After working out a few configuration hiccups, I have the form loading and appears to be working but it always returns false. I am using an LDAP connection string that works in another application so that's not the issue.
I am looking for ways to debug the Login control in order to see where things are falling apart. I see a couple javascript functions that I assume are generated by the login control but they lead to a dead end when the function: ValidatorCommonOnSubmit() is called. That function is not found in the code on the page - so it must in an include somewhere?
Does anyone have some good direction on how to debug a .NET Login control that always returns false?
Here is web.config. These settings work when I use them in a MVC app - but not in webforms. ??
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ADConnectionString" connectionString="LDAP://thing.mycompany.com:389/CN=users,DC=mycompany,DC=com" />
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<pages>
<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 name=".ADAuthCookie" timeout="10"
loginUrl="Login.aspx" defaultUrl="Default.aspx">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DomainLoginMembershipProvider">
<providers>
<clear />
<add name="DomainLoginMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
attributeMapUsername="sAMAccountName"
connectionUsername="username"
connectionPassword="password"
connectionProtection="Secure"
enableSearchMethods="True"
attributeMapEmail="mail"
applicationName="/"
/>
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
It turned out the issue was with the LDAP connection string. When I removed the query string from the connection string it worked. The LDAP connection string that worked was: LDAP://thing.mycompany.com.
The way that I finally came to this answer was when I started doing searches specifically on ActiveDirectoryMembershipProvider instead of focusing on the Login control itself. Thanks to Aristos who pointed me toward the web.config and away from the form.
I have an asp.net web site. I use asp.net login controls generated by the templates and wizards. My tables such as AspNetUsers and AspNetRoles are in the same db as my data.
When I run my site against a local sqlserver database I can use my login controls to login and and everything works fine. When I moved my site to GoDaddy (I also tried on smarterAsp.net with the same problem), my login control works sometimes. Other times it just ignores me and takes me back to the default page with no error message. If I reset the app pool or make a change to the web.config (which seems to reset the app pool), I can log on again for a few times. In IE it is much worse than chrome. In IE I can rarely log on.
In order to trouble shoot my db connection, I added to one of my pages so that I could access it without logging in. After I go to that page which accesses the database, THEN if I go to the login page, I can log in. It seems to me that my login controls are not being allowed to access the db, but my listview control on my page is and then once the connection is opened by the sqlDataSource, then the login control can authenticate. I have wasted a week on this!!! Help!
I am using the same connection string both for the SQLDataSources as well as the aspNet authentication.
Here is my web.config. It might be a little bit of a mess because I have been trying all kind of things. I am only using "LocalSqlServer" connection string.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=ServerIP;Initial Catalog=Aveida;Integrated Security=False;User Id=XXXXX; Password=XXXXXX" providerName="System.Data.SqlClient" />
<remove name = "DefaultConnection"/>
<add name="DefaultConnection" connectionString="Data Source=ServerIP;Initial Catalog=Aveida;Integrated Security=False;User Id=XXXXX; Password=XXXXXX" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<globalization uiCulture="en-US" culture="he-IL" />
<customErrors mode="Off" />
<trust level="Full" />
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
<add namespace="Microsoft.AspNet.Identity" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
<membership>
<providers>
<!--
ASP.NET Membership is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear />
</providers>
</membership>
<profile>
<providers>
<!--
ASP.NET Membership Profile is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear />
</providers>
</profile>
<roleManager>
<!--
ASP.NET Membership Role is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<providers>
<clear />
</providers>
</roleManager>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="LocalSqlServer" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<location path="SearchLost.aspx">
<system.web>
<authorization>
<allow roles="member,manager" />
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Account/Register.aspx">
<system.web>
<authorization>
<allow roles="manager" />
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
I solved the problem. (can't pose an answer for a few more hours)
I changed
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="LocalSqlServer" />
</providers>
to just
<sessionState mode="InProc" >
I got rid of the customProvider (don't know where i got that to begin with) and it seems to work.
Update:
This is the instruction on the server. But following this instruction I cannot find the option "Connect to a site"
I am new to ASP.NET MVC 4 and Razor. Now I have finished my ASP.NET Web Application and I want to upload it to the server and make it accessible to the public.
Previously, I only created websites and upload them to WebCentral (http://www.webcentral.com.au/) by using FX FTP directly and those websites will be accessible immediately.
I have checked that the WebCentral server has the .NET Framework 4.0 version.
Now I want to explore the new advancements in MVC4 and Razor as well as Entity Framework, I chose the ASP.NET MVC 4 web application. After I uploaded this new web application to server, it displays an error:
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: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 22: <system.web>
Line 23: <compilation debug="true" targetFramework="4.0" />
Line 24: <authentication mode="Forms">
Line 25: <forms loginUrl="~/Account/Login" timeout="2880" />
Line 26: </authentication>
Source File: \\n5200-2\iis7_www\z\a\zanity.com.au\www\ce\web.config Line: 24
I have no idea about what shall I do to fix this error.
Please help me if you know how to solve this problem.
Thank you very much.
And this is the Web.configure file
<?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>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MVCTry-20120813175505;Integrated Security=SSPI" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
Update:
I recently found there is an option on the WebCentral Mission Control panel under IIS Management Overview:
1. Select the Web Application folder
2. Select Settings on the right panel
3. Click Install under Install Application section to install the application on the selected folder.
By doing this, the selected folder will become a Web Application folder, then I can put the bin and App_Code and App_Data folders under the Web Application folder.
I finally figured it out.
The reason was I didn't put the bin and App_Code folders in the right direction.
On the WebCentral web server, the Web.config file and App_Code folder should be placed under the current project folder, whereas the bin folder should be placed under the /wwwroot folder.
And I copied all dependencies to the bin folder.
This solved all problems.
I'm happy to know that I can run the latest version of ASP.NET MVC 4 as well as Razor on this web server as long as the nedded DLLs are provided in the bin folder.
Cheers :)
I am getting the following error:
Could not load file or assembly 'System.Web' or one of its dependencies. The system cannot find the file specified.
I'm trying to do an LDAP membership configuration in the Web.Config, and asked the question under that earlier, but I think this may be a more general problem. I'm using the Visual Studio Development server in VS2010/.NET 4.0
Edit: Web.Config Shown below
<?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>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.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="FPLMobileWebApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="LDAPConnectionString" connectionString="LDAP://ad.company.com/CN=Users,DC=company,DC=com" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms name=".ADAuthCookie" loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/FPL/Search" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DomainLoginMembershipProvider">
<providers>
<clear/>
<add name="DomainLoginMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web" connectionStringName="LDAPConnectionString" attributeMapUsername="sAMAccountName" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<applicationSettings>
<FPLMobileWebApp.Properties.Settings>
<setting name="FPLMobileWebApp_FPLdb_Parts" serializeAs="String">
<value>http://a09devlab/pld/parts.asmx</value>
</setting>
</FPLMobileWebApp.Properties.Settings>
</applicationSettings>
</configuration>
EDIT: I simply added the System.Web dll to the bin folder of my application. However, I want to make sure this deploys properly, now it is saying that my connection string does not exist.
I think it's a permission problem.
Look at MSDN.
The ActiveDirectoryMembershipProvider instance works only in the
full-trust policy default configuration of ASP.NET. In order to use
the ActiveDirectoryMembershipProvider instance at any partial-trust
level, either you must make changes to the appropriate trust policy
file for your application or you must create a "sandbox" assembly that
is deployed in the GAC.
The ActiveDirectoryMembershipProvider class
requires unrestricted DirectoryServicesPermission permission to run.
This permission is not added to any of the partial-trust policy files
supplied with ASP.NET. Although adding the DirectoryServicesPermission
permission to a partial-trust policy file will enable use of the
ActiveDirectoryMembershipProvider class, doing so makes the
System.DirectoryServices namespace classes available to any code
running in your ASP.NET pages. This option is not recommended for any
Web servers that need to run in a secure, locked-down mode.
As an
alternative, you can create a "sandbox" assembly that calls the
ActiveDirectoryMembershipProvider class. This assembly can contain
either a wrapper class that forwards method calls to the
ActiveDirectoryMembershipProvider class or a class that derives from
the ActiveDirectoryMembershipProvider class. In either case, the
wrapper class must assert unrestricted DirectoryServicesPermission
permission. Deploy the sandbox assembly in the GAC and mark the
assembly with the AllowPartiallyTrustedCallersAttribute (APTCA)
attribute. This will enable your partially trusted ASP.NET code to
call your wrapper class, and since the wrapper class internally
asserts the unrestricted DirectoryServicesPermission permission, your
wrapper class will be able to successfully call the provider
So, the easiest way to solve the problem (if you are really facing a security problem) is to set full trust policy to your application.
How to do it? Look at Technet
Long and short my machine had issues and I had to rebuild it. I reinstalled all my software and put my project backups back on the machine. I have been trying to solve SQL connect issues that I just can't get around.
So after going through many changes and error, I put the working production version back on my machine. When I run it I get the following error:
Parser Error Message: Unknown database 'p10009307_sec'
The Database is known to my SQL Workbench and If I drop a Database connection on a page and configure it I can connect.
The Question is where is it looking that it can't find MySQL? I assume its in the Webconfig, but I don't see anything out of the ordinary that would make localhost diffrent. I made a copy of my webconfig with only the sections that refrence MySQL.
`<connectionStrings>
<remove name="LocalMySqlServer" />
<add name="LocalMySqlServer" connectionString="server=localhost;password=xxxxxxxxxx;
User Id=xxxxxxxxxx;logging=True;database=xxxxxxxxxx_sec" providerName="MySql.Data.MySqlClient" />
<add name="'LocalSqlServer" connectionString="server=localhost;database=xxxxxxxxxx_CUS;
logging=True;password=xxxxxxxxxx;User Id=xxxxxxxxxxER" providerName="MySql.Data.MySqlClient" />
<remove name="LocalSqlServer" />
<add name="p10009307_cusConnectionString" connectionString="server=localhost;
User Id=xxxxxxxxxxER;password=xxxxxxxxxx;database=xxxxxxxxxx_CUS"
providerName="MySql.Data.MySqlClient" />
<add name="p10009307_cusConnectionString2" connectionString="server=localhost;
User Id=xxxxxxxxxER;password=xxxxxxxxxx;database=xxxxxxxxxx_CUS;
SQL SERVER MODE=True" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySQL.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySQL.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<system.web>
<customErrors mode="Off" />
<compilation targetFramework="4.0" debug="true">
<assemblies>
<add assembly="MySql.Data, Version=6.4.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" />
</assemblies>
</compilation>
<authorization>
<allow roles="Admin" />
</authorization>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership defaultProvider="MySQLMembershipProvider">
<providers>
<clear />
<remove name="MySQLMembershipProvider" />
<add name="MySQLMembershipProvider"
type="MySql.Web.Security.MySQLMembershipProvider,
MySql.Web, Version=6.4.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" applicationName="/"
description="Membership Provider"
connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="True"
autogenerateschema="True"
enablePasswordRetrieval="False"
enablePasswordReset="True"
requiresQuestionAndAnswer="False"
requiresUniqueEmail="False" passwordFormat="Clear"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<profile defaultProvider="MySQLProfileProvider">
<providers>
<clear />
<remove name="MySQLProfileProvider" />
<add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider,
MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
applicationName="/" description="Profile provider"
connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False"
autogenerateschema="True" />
</providers>
</profile>
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
<providers>
<clear />
<remove name="MySQLRoleProvider" />
<add applicationName="/" description="Role Provider" connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="True" autogenerateschema="True" name="MySQLRoleProvider"
type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.4.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d" />
</providers>
</roleManager>
<sessionState mode="Custom" cookieless="true" regenerateExpiredSessionId="true"
customProvider="MySqlSessionStateProvider">
<providers>
<add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore,
MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"
applicationName="/" description="State Provider" connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="True" autogenerateschema="True" />
</providers>
</sessionState></system.web>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.3.7.0" newVersion="6.4.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>`
Everything is running local host at this point I have put the DLL's in the bin directory, I don't know what i am missing.
I don't see anything in that config snippet that tells the "MySQL Data Provider" which one out of available conn-strings to use.
There's got to be something in the code that tells it either the conn-string name or the conn-string value. Something like this:
System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString
Also, your 2nd conn-string has a single-quote character right before its name: 'LocalSqlServer
Perhaps you accidentally added it, and now the conn string cannot be found by the name of "LocalSqlServer" (if that's the one that's the problem, anyway).
If you want to use the MySQL database to store the session, you have to declare this in the Sessionstate of the web.config. Furthermore you have to look into the machine.config file if all the MySQL providers are set.