asp.net login controls always work with local sqlserver but only intermittently on hosted server - asp.net

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.

Related

How to resolve 404 Server error.Received when web is deploy on domain

When i deploy my website got this error.
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
My config code is as follow.
dont know what and where i'm missing something.However i have deploy the same project once on #somee where it work perfect.
<?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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="YourConnectionString" connectionString="Data Source=juhi;Initial Catalog=kingston_DB;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/>
<add name="kingston_DBEntities" connectionString="metadata=res://*/CollegeModel.csdl|res://*/CollegeModel.ssdl|res://*/CollegeModel.msl;provider=System.Data.SqlClient;provider connection string="data source=juhi;initial catalog=kingston_DB;integrated security=True;multipleactiveresultsets=True;connect timeout=30;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Need suggestion to resolve this error.
The second connection string looks odd to me:
<add name="kingston_DBEntities"
connectionString="metadata=res://*/CollegeModel.csdl|res://*/CollegeModel.ssdl|res://*/CollegeModel.msl;
provider=System.Data.SqlClient;
provider <-- here
connection string=" <-- here
data source=juhi; <-- here ?
initial catalog=kingston_DB;
integrated security=True;
multipleactiveresultsets=True;
connect timeout=30;
application name=EntityFramework"" <- here
providerName="System.Data.EntityClient" />

How to debug ASP: Login control that always returns false?

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.

ASP.NET cannot get rid of "500- Internal server error"

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.

How do I setup an asp.net web application on a remote server

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 :)

LoginView works in Account folder, not in root folder of website

I have been searching the internet for an answer to my problem and have read through the msdn site on ASP.Net controls, security and authentication but either cannot find the answer or missed it with all the information I have read.
I am building a website in ASP.Net v2.0 to be hosted on a remote server. I am using MySQL as the back end which also contains the user tables. I have used the same user table structure as that used in the default membership table. The folders in the application all have the default role privileges assigned to them.
The following problem is occurring in my testing on my local computer.
When I login a user using the ~/Account/Login.aspx page I redirect the user to ~/Account/AccountDetails.aspx, which contains a LoginView. After logging in, the user name is visible on this page inside the LoginView and they are Authenticated.
When I then go to ~/Default.aspx, and using the same code for the LoginView, the username is not displaying and they are no longer Authenticated.
I do not want to create multiple pages to show the same data, as both logged in and anonymous users need to see the same information in the ~/Default.aspx page. I was just hoping to show that the user is logged in on the Default.aspx page or any page in the ~/ folder.
I know it is going to be a simple setting or change that is required, like a role or membership or something, but I cannot figure it out.
I have looked through stackoverflow and found a lot of LoginView questions, but cannot seem to find one that answers my question.
I was hoping someone might be able to point me in the right direction.
Here is the code used on both the Default.aspx and AccountDetails.aspx pages. It is the default LoginView code from the template ASP.Net website application.
<div class="loginDisplay">
User Authenticated? <%= Page.User.Identity.IsAuthenticated %>
<asp:LoginView ID="HeadLoginView" runat="server">
<AnonymousTemplate>
[ Log In ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
The ~/Account/web.config file contains the following:
<?xml version="1.0"?>
<configuration>
<location path="Register.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>
The ~/web.config file contains the following information. I have edited some of the values for username and passwords. I have also removed the commented lines.
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="MySqlMembershipConnection" connectionString="Data Source=mydatasource;user id=dotnet;password=dotnet;" providerName="MySql.Data.MySqlClient" />
<add name="mycs" connectionString="Dsn=mydsn" providerName="System.Data.Odbc" />
<remove name="LocalMySqlServer" />
<add name="LocalMySqlServer" connectionString="database=mydsn;server=localhost;User Id=dotnet;password=dotnet" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.web>
<sessionState mode="Custom" cookieless="false" 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="" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" />
</providers>
</sessionState>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="30" name=".ASPXFORM$" path="~/" requireSSL="false" slidingExpiration="true" defaultUrl="~/Default.aspx" enableCrossAppRedirects="false" />
</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="mydescription" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" enablePasswordRetrieval="False" enablePasswordReset="True" requiresQuestionAndAnswer="True" 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="" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" />
</providers>
</profile>
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
<providers>
<clear />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
<add applicationName="/" description="" connectionStringName="LocalMySqlServer"
writeExceptionsToEventLog="False" autogenerateschema="True"
name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</providers>
</roleManager>
<customErrors mode="Off" />
<compilation debug="true" />
</system.web>
<system.net>
<mailSettings>
<smtp from="user#domain.com">
<network host="mail.domain.com" password="mypassword" userName="myusername" />
</smtp>
</mailSettings>
</system.net>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
So after much testing I figured out where the problem was. Firstly, I had three connection strings, one for the data and two for the forms authentication. I combined the two forms authentication connection strings into a single connection string. This allows me to have one connection string for data and one for authentication.
Next, I wanted to find out where my problem was occurring, so I created a new blank ASP.NET website in VS 2010 and then step by step, added in support for MySQL. This was done by adding in the MySQL Data and Web references first, then the connection strings and then finally the forms authentication.
I noticed in the forms element in the system.web authentication element, that it only included the loginURL and timeout attributes, so I tested the application by adding in additional attributes for the forms element until I found the attribute causing the problem.
In my forms element the path attribute was set to '~/'. When I changed this to '/' the application started to work correctly.

Resources