2009-05-07 2 views
0

У меня возникла эта проблема; Я разрабатываю сайт с ASP.Net 2005, база данных, которую я использую, - это MySQL, а веб-сервер - Cassini, также я использую Authentication Forms для обработки доступа к страницам.Проблемы со страницей входа

Я делал тесты на всех компьютерах, обращающихся к сайту, однако вчера, когда я обратился к сайту с ПК, страница входа в систему была представлена, но когда я нажимаю кнопку для аутентификации, я остаюсь на той же странице входа.

Я не знаю, что происходит, потому что я могу получить доступ к страницам на сервере, но доступ с любого другого терминала оставляет меня на странице входа в систему без доступа к самому сайту (программе).

Что здесь не так?

Это код кнопки входа

 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; 
     } 

Это 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> 
+0

Вы уверены, что на другом терминале, к которому вы пытаетесь получить доступ к сайту, не отключены файлы cookie? –

+0

и проверили на ошибки javascript? – womp

+0

все терминалы принимают файлы cookie –

ответ

0

Первое правило из проблемы с компьютером вы можете запустить скрипач (Google это некоторые разработчики MS написали его) на ПК, чтобы проверить, что подача обрабатывается сервером. Если его не переходить на веб-сервер, тогда это может быть проблема с прокси-сервером, которая блокирует просмотр компьютера или разрешение на использование javascript, чтобы кнопка не была отправлена.

Если это соединение, то я бы проверял, что запрос db проходит (вы изменили имя пользователя и пароль в web.config выше, я надеюсь.) Если это нормально; правильные настройки разрешений на страницу; на моих сайтах у web.config есть намного больше настроек авторизации.

<location path="css"> 
    <system.web> 
     <authorization> 
     <allow users="*"/> 
     </authorization> 
    </system.web> 
    </location> 
</configuration> 
Смежные вопросы