2011-02-16 80 views
0

我正在使用連接到遠程SQL DB的createwizard。用戶創建好並顯示在數據庫中。ASP.NET會員資格。創建用戶作品,但無法登錄?

我也有登錄控制,但是在我輸入用戶名和密碼後,我無法登錄,它只是坐在登錄屏幕上。我需要看什麼?

我經歷了asp.net配置工具,並設置了持有我的認證/成員頁面的目錄來拒絕任何不認識的人。對於登錄

<%@ Page Title="Login" Language="C#" MasterPageFile="~/Account/LoginMaster.Master" AutoEventWireup="true" 
CodeBehind="Default.aspx.cs" Inherits="BT4SGWebApplication.Account.Login" %> 

<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server"> 
</asp:Content> 
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> 
    <div style="border-style: none; border-width: thin; height: 565px; top: -3px; left: -5px; width: 922px; position: relative;"> 
     <div style="border-style: solid; border-width: thin; height: 370px; width: 360px; top: 95px; left: 420px; position: absolute"> 
      <asp:Login ID="LoginField" runat="server" 


       style="position: absolute; top: 89px; left: 71px; height: 132px; width: 217px" 
       MembershipProvider="MySqlLoginProvider"> 
       <LayoutTemplate> 
        <table cellpadding="1" cellspacing="0" style="border-collapse:collapse;"> 
         <tr> 
          <td> 
           <table cellpadding="0"> 
            <tr> 
             <td align="center" colspan="2"> 
              Log In</td> 
            </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="UserName" runat="server"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
               ControlToValidate="UserName" ErrorMessage="User Name is required." 
               ToolTip="User Name is required." ValidationGroup="LoginField">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
            <tr> 
             <td align="right"> 
              <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> 
             </td> 
             <td> 
              <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox> 
              <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
               ControlToValidate="Password" ErrorMessage="Password is required." 
               ToolTip="Password is required." ValidationGroup="LoginField">*</asp:RequiredFieldValidator> 
             </td> 
            </tr> 
            <tr> 
             <td colspan="2"> 
              <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." /> 
             </td> 
            </tr> 
            <tr> 
             <td align="center" colspan="2" style="color:Red;"> 
              <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal> 
             </td> 
            </tr> 
            <tr> 
             <td align="right" colspan="2"> 
              <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" 
               ValidationGroup="LoginField" PostBackUrl="~/Tabs/Home.aspx" /> 
             </td> 
            </tr> 
           </table> 
          </td> 
         </tr> 
        </table> 
       </LayoutTemplate> 
      </asp:Login> 
      <asp:Label ID="loginLabel" runat="server" BackColor="White" BorderColor="White" 
       Font-Bold="True" Font-Size="XX-Large" 
       style="height: 42px; width: 100px; top: 30px; left: 128px; position: absolute; border-style: solid; border-width: thin" 
       Text="Log In"></asp:Label> 
      <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" 

       style="top: 253px; left: 28px; position: absolute; height: 102px; width: 304px"> 
      </asp:PasswordRecovery> 
     </div> 
     <asp:Button ID="Button1" runat="server" BorderColor="Black" BorderStyle="Solid" 
      BorderWidth="8px" Font-Bold="True" Font-Size="X-Large" 
      style="top: 233px; left: 150px; height: 53px; width: 232px; position: absolute; border-style: solid; border-width: thin" 
      Text="Click to Register" onclick="Button1_Click" /> 
    </div> 
</asp:Content> 

的web.config

源代碼

<configuration> 

    <connectionStrings> 
     <add name="LoginSQL" providerName="System.Data.SqlClient" connectionString="Data Source=xx.xx.xx.xx;Initial Catalog=xxxx;UID=xxxx;pwd=xxxxx;"/> 
    </connectionStrings> 

    <system.web> 
     <compilation debug="true" targetFramework="4.0"> 
      <assemblies> 
       <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> 
       <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
       <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation> 

     <authentication mode="Forms"> 
    <forms name="Login" loginUrl="Default.aspx" timeout="20" /> 
    </authentication> 

    <membership defaultProvider="MySqlLoginProvider"> 
      <providers> 
       <add name="MySqlLoginProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LoginSQL" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" passwordAttemptWindow="30" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"/> 
      </providers> 
     </membership> 

     <profile> 
      <providers> 
       <clear/> 
       <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> 
      </providers> 
     </profile> 

     <roleManager cacheRolesInCookie="true" cookieName=".ASPRoles" 
    cookieTimeout="60" defaultProvider="AspNetWindowsTokenRoleProvider"> 

    <providers> 
    <add connectionStringName="LoginSQL" applicationName="/" name="MyRoleProvider" 
    type="System.Web.Security.SqlRoleProvider" /> 
    </providers> 

    </roleManager> 
    </system.web> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 
+0

瀏覽器的登錄嘗試是否超時?如果是這樣,完整的超時消息是什麼?這可能會更有價值,你的web.config。 – 2011-02-16 23:55:33

回答

1

您可能需要確認RETURNURL查詢字符串參數不指向你回到登錄頁面。另外,請嘗試在登錄控制本身上指定DestinationPageUrl屬性。

更新看着你的代碼,這是問題所在。您被默認重定向到default.aspx,這是您的登錄頁面。要麼將登錄頁面重命名爲login.aspx,要麼如上所述手動指定重定向頁面。

相關問題