Login page issues
I have this problem; I am developing a site with ASP.Net 2005, the database I am using is MySQL and the webserver is Cassini, also I am using forms authentication to handle page access.
I have done tests on all computers accessing the site, however yesterday when I accessed the site from the PC, the login page was presented, but when I click the button to authenticate I stay on the same login page.
I don't know what's going on because I can access the pages on the server, but access from any other terminal it keeps me on the login page without accessing the site (program) itself.
What's wrong here?
This is the login button code
qfh.User user = qfh.Global.Login(txtUserName.Text, txtPassword.Text, null, null);
if (user != null)
{
// Initialize FormsAuthentication, for what it worth
FormsAuthentication.Initialize();
// Create a new ticket used for authentication
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
user.UserName, // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(30), // Date/time to expire
true, // "true" for a persistent user cookie
string.Join(",", user.GetRoles()), // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);// Path cookie valid for
//Fill the complementary data
Profile.User = user.UserName;
Profile.Name = user.Name;
//Profile.Enterprise = user.Enterprise.EnterpriseCode; // enterprise.EnterpriseCode;
//Profile.Period = user.Enterprise.GetActivePeriod().PeriodCode; //enterprise.GetActivePeriod().PeriodCode;
Session["Enterprise"] = user.Enterprise.EnterpriseCode;
Session["Period"] = user.Enterprise.GetActivePeriod().PeriodCode;
// Encrypt the cookie using the machine key for secure transport
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie
hash); // Hashed ticket
// Set the cookie expiration time to the tickets expiration time
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
// Add the cookie to the list for outgoing response
Response.Cookies.Add(cookie);
// Redirect to requested URL, or homepage if no previous page
// requested
string returnUrl = Request.QueryString["ReturnUrl"];
if (returnUrl == null) returnUrl = "/";
// Don't call FormsAuthentication.RedirectFromLoginPage since it
// could
// replace the authentication ticket (cookie) we just added
Response.Redirect(returnUrl);
}
else
{
lblStatusMessage.Text = Utilities.JSAlert("Access denied");
return;
}
This is web.config
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"/>
</configSections>
<appSettings>
<add key="QFH" value="QFH2009" />
</appSettings>
<activerecord isWeb="true">
<config>
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect"/>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.connection.connection_string" value="Server=localhost;Database=qfh;User ID=root;Password=admin;Pooling=false;Min Pool Size=5;Max Pool Size=100;"/>
</config>
</activerecord>
<connectionStrings>
<!--<add name="QFHConnectionString" connectionString="Dsn=QFH" providerName="System.Data.Odbc"/>-->
<add name="QFHConnectionString" connectionString="Server=localhost;Database=qfh;User ID=root;Password=admin;Pooling=false;Min Pool Size=5;Max Pool Size=100;"/>
</connectionStrings>
<system.web>
<roleManager defaultProvider="MySqlRoleProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="All" >
<providers>
<clear />
<add
name="MySqlRoleProvider"
type="Andri.Web.MySqlRoleProvider"
connectionStringName="QFHConnectionString"
applicationName="QFH"
writeExceptionsToEventLog="true"
/>
</providers>
</roleManager>
<membership defaultProvider="MySqlMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="MySqlMembershipProvider"
type="Andri.Web.MySqlMembershipProvider"
connectionStringName="QFHConnectionString"
applicationName="QFH"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true"
passwordFormat="Hashed"
writeExceptionsToEventLog="true"
/>
</providers>
</membership>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<httpModules>
<add name="ar.sessionscope" type="Castle.ActiveRecord.Framework.SessionScopeWebModule, Castle.ActiveRecord"/>
</httpModules>
<compilation debug="true">
<assemblies>
<add assembly="MySql.Data, Version=5.1.7.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<!--<roleManager enabled="false"/>-->
<authentication mode="Forms">
<forms name="QFHWEBAPP.ASPXAUTH" loginUrl="Login.aspx" defaultUrl="Default.aspx" />
</authentication>
<authorization>
<!-- Do not allow all users come in -->
<deny users="?"/>
</authorization>
<anonymousIdentification enabled="true"/>
<!-- Temporary fields for the session -->
<profile defaultProvider="MySQLProfileProvider">
<providers>
<!--<add name="MySqlProfileProvider"
type="Malachi.MySqlProviders.MySqlProfileProvider"-->
<add name="MySQLProfileProvider"
type="Ezim.MySql.Web.Profile.MySqlProfileProvider"
connectionStringName="QFHConnectionString"
applicationName="QFH"/>
</providers>
<properties>
<add name="User" allowAnonymous="true" type="System.String"/>
<add name="Name" allowAnonymous="true" type="System.String"/>
<add name="Period" allowAnonymous="true" type="System.Int32"/>
<add name="Enterprise" allowAnonymous="true" type="System.Int32"/>
</properties>
</profile>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<customErrors mode="Off" />
</system.web>
<!--This code is used to make available the css-->
<location path="css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
a source to share
Eliminate PC problems first, you can run fiddler (as some MS devs wrote on the computer) to check that the feed is being handled by the server. If its not going to the web server then it might be a proxy server issue that is blocking the computer from viewing your site or allowing javascript to prevent the button from being sent.
If it connects, I would check that the db request passes (you actually changed the username and password in the web.config above, I hope.) If that's ok; correct settings for permissions on the page; on my sites web.config has a lot more authorization settings.
<location path="css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
a source to share