简体   繁体   中英

Button working everywhere but default.aspx

I have an ASP.NET page which has a usercontrol to log in a user. The control appears on every page, and works everywhere except default.aspx. When I click it on default.aspx, the page posts back to the same page and get a 404. Failed request tracing doesn't seem to reveal anything. The code for the button is:

<asp:Button ID="Button1" runat="server" Text="Sign In" OnClick="btnLogin_Click" />

I can't see any reason this shouldn't work.

I believe you may be redirecting to default.aspx on login. It works everywhere else because you are redirecting to the default but breaks when you are on default.aspx itself.

Check the login redirect function in debug mode and see what exactly is happening.

Look for multiple forms in the rendered source, and make sure your button occurs within the form. This can cause lots of problems with postback.

To be more clear. No nested forms. Asp:buttons or anything that uses postback MUST be inside the page's singular unnested form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM