Problems with the Login Page
<p>I have this problem; I'm developing a site with ASP.Net 2005, the database I use is MySQL and the Web Server is Cassini, also I use Forms Authentication to handle the access to the pages.</p>

<p>I was making tests in all the computers accessing the site, however yesterday when I accessed the site from a PC the login page is presented but when I press the button to authenticate I stay in the same login page.</p>

<p>I don't know what is going because I can access the pages in the server but accessing from any other terminal it keeps me in the login page without accessing to the site (program) itself.</p>

<p>What is wrong here?</p>

<p>This is the code of the login button</p>

<pre><code>        qfh.User user = qfh.Global.Login(txtUserName.Text, txtPassword.Text, null, null);
        if (user != null)
        {
            // Initialize FormsAuthentication, for what it's 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's 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;
        }
</code></pre>

<p>This is the web.config</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;!-- 
    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-&gt;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 
--&gt;
&lt;configuration&gt;

  &lt;configSections&gt;
    &lt;section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord"/&gt;
  &lt;/configSections&gt;

  &lt;appSettings&gt;
    &lt;add key="QFH" value="QFH2009" /&gt;
  &lt;/appSettings&gt;

  &lt;activerecord isWeb="true"&gt;
    &lt;config&gt;
      &lt;add key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/&gt;
      &lt;add key="hibernate.dialect" value="NHibernate.Dialect.MySQLDialect"/&gt;
      &lt;add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/&gt;
      &lt;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;"/&gt;
    &lt;/config&gt;
  &lt;/activerecord&gt;

  &lt;connectionStrings&gt;
    &lt;!--&lt;add name="QFHConnectionString" connectionString="Dsn=QFH" providerName="System.Data.Odbc"/&gt;--&gt;
    &lt;add name="QFHConnectionString" connectionString="Server=localhost;Database=qfh;User ID=root;Password=admin;Pooling=false;Min Pool Size=5;Max Pool Size=100;"/&gt;
  &lt;/connectionStrings&gt;

  &lt;system.web&gt;

    &lt;roleManager defaultProvider="MySqlRoleProvider"
        enabled="true"
        cacheRolesInCookie="true"
        cookieName=".ASPROLES"
        cookieTimeout="30"
        cookiePath="/"
        cookieRequireSSL="false"
        cookieSlidingExpiration="true"
        cookieProtection="All" &gt;

      &lt;providers&gt;
        &lt;clear /&gt;
        &lt;add
            name="MySqlRoleProvider"
            type="Andri.Web.MySqlRoleProvider"
            connectionStringName="QFHConnectionString"
            applicationName="QFH"
            writeExceptionsToEventLog="true"
        /&gt;
      &lt;/providers&gt;

    &lt;/roleManager&gt;

    &lt;membership defaultProvider="MySqlMembershipProvider" userIsOnlineTimeWindow="15"&gt;

      &lt;providers&gt;
        &lt;clear /&gt;
        &lt;add
            name="MySqlMembershipProvider"
            type="Andri.Web.MySqlMembershipProvider"
            connectionStringName="QFHConnectionString"
            applicationName="QFH"
            enablePasswordRetrieval="false"
            enablePasswordReset="true"
            requiresQuestionAndAnswer="true"
            requiresUniqueEmail="true"
            passwordFormat="Hashed"
            writeExceptionsToEventLog="true"
            /&gt;
      &lt;/providers&gt;

    &lt;/membership&gt;

    &lt;!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.

        --&gt;

    &lt;httpModules&gt;
      &lt;add name="ar.sessionscope" type="Castle.ActiveRecord.Framework.SessionScopeWebModule, Castle.ActiveRecord"/&gt;
    &lt;/httpModules&gt;

    &lt;compilation debug="true"&gt;
      &lt;assemblies&gt;
        &lt;add assembly="MySql.Data, Version=5.1.7.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/&gt;
        &lt;add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
        &lt;add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
      &lt;/assemblies&gt;
    &lt;/compilation&gt;

    &lt;!--
            The &lt;authentication&gt; section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        --&gt;
    &lt;!--&lt;roleManager enabled="false"/&gt;--&gt;

    &lt;authentication mode="Forms"&gt;
      &lt;forms name="QFHWEBAPP.ASPXAUTH" loginUrl="Login.aspx" defaultUrl="Default.aspx" /&gt;
    &lt;/authentication&gt;

    &lt;authorization&gt;
      &lt;!-- Do not allow all users come in --&gt;
      &lt;deny users="?"/&gt;
    &lt;/authorization&gt;

    &lt;anonymousIdentification enabled="true"/&gt;

    &lt;!-- Temporary fields for the session --&gt;
    &lt;profile defaultProvider="MySQLProfileProvider"&gt;
      &lt;providers&gt;
        &lt;!--&lt;add name="MySqlProfileProvider"
     type="Malachi.MySqlProviders.MySqlProfileProvider"--&gt;
        &lt;add name="MySQLProfileProvider"
             type="Ezim.MySql.Web.Profile.MySqlProfileProvider"
             connectionStringName="QFHConnectionString"
             applicationName="QFH"/&gt;
      &lt;/providers&gt;
      &lt;properties&gt;
        &lt;add name="User" allowAnonymous="true" type="System.String"/&gt;
        &lt;add name="Name" allowAnonymous="true" type="System.String"/&gt;
        &lt;add name="Period" allowAnonymous="true" type="System.Int32"/&gt;
        &lt;add name="Enterprise" allowAnonymous="true" type="System.Int32"/&gt;
      &lt;/properties&gt;
    &lt;/profile&gt;
    &lt;!--
            The &lt;customErrors&gt; 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.

        &lt;customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"&gt;
            &lt;error statusCode="403" redirect="NoAccess.htm" /&gt;
            &lt;error statusCode="404" redirect="FileNotFound.htm" /&gt;
        &lt;/customErrors&gt;
        --&gt;
    &lt;customErrors mode="Off" /&gt;
  &lt;/system.web&gt;

  &lt;!--This code is used to make available the css--&gt;
  &lt;location path="css"&gt;
    &lt;system.web&gt;
      &lt;authorization&gt;
        &lt;allow users="*"/&gt;
      &lt;/authorization&gt;
    &lt;/system.web&gt;
  &lt;/location&gt;
&lt;/configuration&gt;
</code></pre>
