1

I'm facing a severe problem - my ASP application doesn't see the Breakpoints. I've read this Why Arent Breakpoints Working In Web Application Project. But it didn't help. I'm using VS2010 and the page is loaded in IE.

Here's my web.config file

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

I start my application simply clicking F5 in VisualStudio. Does anybody know what the mistake is, please?

This is my 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");
        }
    }
}

And here's its interface.

<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>
5
  • Are you running the project in debug or release mode? Commented Dec 12, 2012 at 9:39
  • @LeviBotelho, the application is in Debug mode
    – Ermintar
    Commented Dec 12, 2012 at 9:50
  • Do any breakpoints work (for example at the very start of the application) or none at all? Commented Dec 12, 2012 at 10:12
  • @LeviBotelho Oh, thanks you've hit the point I forgot to check... Yeah, the breakpoints in the Page_Load section work, but in the button section it doesn't. I'll print the button code bellow
    – Ermintar
    Commented Dec 12, 2012 at 10:27
  • If you Start Debugging and hover over the breakpoint for the button code in the code-behind, what does the debugger say? There should be a tooltip that shows when you hover over a breakpoint indicating why it's not loaded. That message has a good amount of bearing on the answer. Commented Dec 12, 2012 at 10:47

1 Answer 1

4

You need to add an OnClick="LoginButton_Click" attribute to your <asp:Button...> item to hook the button to the event.

Read more here, or use CommandName / CommandArgument.

You are doing a bit of both and that is why it is not working as you expect.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.