2012-12-12 41 views
1

我正面臨嚴重的問題 - 我的ASP應用程序沒有看到斷點。 我讀過這個Why Arent Breakpoints Working In Web Application Project。但它沒有幫助。 我使用VS2010,並在IE中加載頁面。ASP.NET應用程序未命中斷點

這裏是我的web.config文件

<configuration> 
    <connectionStrings> 
    <add name="ApplicationServices" 
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" 
     providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

    <system.web> 
    <siteMap enabled="true"> 
     <providers> 
     <clear/> 
     <add siteMapFile="Web.sitemap" name="AspNetXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/> 
     </providers> 
    </siteMap> 

    <compilation debug="true" targetFramework="4.0" /> 

    <authentication mode="Forms"> 
     <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> 
    </authentication> 

    <membership> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" 
      enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" 
      maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" 
      applicationName="/" /> 
     </providers> 
    </membership> 

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

    <roleManager enabled="false"> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> 
     <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> 
     </providers> 
    </roleManager> 

    </system.web> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 


</configuration> 

我開始我的應用程序,只需點擊的VisualStudio中F5。 有人知道錯誤是什麼嗎?

這是我Login.aspx.cs

public partial class Login : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); 
    } 

    protected void LoginButton_Click(object sender, EventArgs e) 
    { 
     var userNameTextBox = LoginUser.FindControl("UserName") as TextBox; 
     var passwordTextBox = LoginUser.FindControl("Password") as TextBox; 
     if (userNameTextBox != null && passwordTextBox != null) 
     { 
      bool succes = UserDAL.Login(userNameTextBox.Text, passwordTextBox.Text); 
      if (succes == true) 
       Server.Transfer("~/Account/Succes.aspx"); 
     } 
    } 
} 

下面是它的界面。

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
<center> 
    <p> 
     Введите имя пользователя и пароль. 
     <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> если у вас нет учетной записи. 
    </p> 
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"> 
     <LayoutTemplate> 
      <span class="failureNotification"> 
       <asp:Literal ID="FailureText" runat="server"></asp:Literal> 
      </span> 
      <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
       ValidationGroup="LoginUserValidationGroup"/> 
      <div class="accountInfo"> 
       <fieldset class="login"> 
        <legend>text</legend> 
        <p> 
         <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Login:</asp:Label> 
         <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> 
         <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
          CssClass="failureNotification" ErrorMessage="" ToolTip="" 
          ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> 
        </p> 
        <p> 
         <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> 
         <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> 
         <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
          CssClass="failureNotification" ErrorMessage="" ToolTip="" 
          ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> 
        </p> 
       </fieldset> 
       <p class="submitButton"> 
        <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Выполнить вход" ValidationGroup="LoginUserValidationGroup"/> 
       </p> 
      </div> 
     </LayoutTemplate> 
    </asp:Login> 
</center> 
</asp:Content> 
+0

您是否在調試或發佈模式下運行項目? –

+0

@LeviBotelho,應用程序處於調試模式 – Ermintar

+0

是否有任何斷點工作(例如在應用程序開始時)或根本沒有? –

回答

4

你需要一個OnClick="LoginButton_Click"屬性添加到您的<asp:Button...>項目掛鉤的按鈕事件。

Read more here或使用CommandName/CommandArgument

您正在做這兩件事,這就是爲什麼它沒有按照您的預期工作。

+0

哦,謝謝!這解決了問題! – Ermintar

相關問題