0

I have an ASPX based solution that is running under .NET 4.8 and IIS 6.2. We have a login screen.

When a user enters their username and password, then hits enter or clicks enter, they should be logged in. The problem we are having is, if a user clicks the login button everything is fine but if they hit enter, the page seems to refresh but not postback.

Some history...We had this issue years ago when we were hosted under GoDaddy. There was some IIS setting that they changed at some point that broke our app and caused this. They wouldn't undo this as the setting (they wouldn't tell me what setting) would apply to others on the same IIS. We moved to a new host and now have our own IIS running on its on box. We have not had this issue for years and now recently it has cropped back up again. When I test this code locally under IIS Express via Visual Studio, we do not have the problem. When I publish to our server, the problem arises.

I am pulling my hair out on this one.

EDIT 2020-10-09 - Added markup

    <form id="Form1" runat="server">
        <div class="container" id="container" runat="server">
            <div class="row">
                <div class="col-md-4">
                    &nbsp;</div>
                <div class="col-md-4">
                    <p style="text-align: center;">
                        <img src="./images/logo160x300.png" />
                    </p>
                    <h2>
                        Sign In</h2>
                    <div id="errorPanel" runat="server" style="display: none;">
                        <asp:label ID="lblAuthenticationFailure" runat="server" Text="Login failed. Please check your username and password."
                            Visible="True" Font-Bold="True" ForeColor="#CC0000"></asp:label>
                        <br />
                        <br />
                    </div>
                    <label for="txtUser">
                        Email</label>
                    <asp:TextBox ID="txtUser" runat="server" placeholder="Email" type="email" class="form-control"
                        required autofocus AutoComplete="username"></asp:TextBox>
                    <br />
                    <label for="txtPassword">
                        Password</label>
                    <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" placeholder="Password"
                        class="form-control" required AutoComplete="current-password"></asp:TextBox>
                    <div class="text-right small">
                        <a href="forgotpassword.aspx">Forgot your password?</a></div>
                    <br />
                    <asp:Button ID="butLogin" runat="server" Text="Sign in" type="submit" class="btn btn-lg btn-primary btn-block" />
                    <br />
                    <div class="text-center">
                        New? Need an Account?<br />
                    </div>
                    <a class="btn btn-default btn-lg btn-block" href="createlogin.aspx" role="button">Create
                        an account</a>
                    <br />
                </div>
            </div>
        </div>
    </form>
  • Some additional information that I discovered last night. My login page is suffering from this problem, but when I use my "forgot password" page, the default button works fine. So the issue is not site wide but appears to be page specific. I am trying to identify the differences and what may have changed (which is odd because we were in a code freeze for months when this happened) to see if that helps diagnose the issue. – user3440517 Sep 18 '20 at 13:09
  • Further update. I have this code deployed in a subdomain off of our main domain. In our old test environment/domain, this code works. In the new subdomain, the code doesn't work and exhibits this broken submit button behavior. I do not think this is the code. I think it's environmental. Something related to the IIS. – user3440517 Oct 09 '20 at 21:03
  • Further update, I think I have narrowed this a bit further. In the site where this works, the code is deployed to the root of https://subdomain.domain.com/. In the site(s) where this fails, the code is deployed to https://subdomain.domain.com/folder/. There is something about this code being deployed in a subfolder that breaks the default button the default.aspx. – user3440517 Oct 30 '20 at 15:23

2 Answers2

0

In your form tag set the defaultButton to the login button.

  <form id="form1" runat="server" defaultbutton="IdOfSubmitbutton">
JobesK
  • 347
  • 1
  • 2
  • 6
  • Yes, I have tried setting the default in the mark up AND in the page load event. Neither option worked. – user3440517 Sep 18 '20 at 13:07
  • @JobesK...I edited the original post to add the markup. I did not post the code behind, because in this situation, it never gets called. – user3440517 Oct 09 '20 at 20:22
0

You can set the default postback button on PageLoad by

Page.Form.DefaultButton = myButton;

Make sure you do a search. This has probably been answered.

wazz
  • 4,953
  • 5
  • 20
  • 34
  • Yes, I have tried setting the default in the mark up AND in the page load event. Neither option worked. And I promise you, I have spent hours researching this. I cannot find the answer anywhere. – user3440517 Sep 18 '20 at 13:08