简体   繁体   中英

Button Event Handler Not Firing on Homepage Without /default.aspx

I'm at a loss over here. On the root of my application (default.aspx), I have a basic ASP.NET Button control on the page with an event handler wired up via its onClick event.

Since it's the root, hitting either / or default.aspx will bring you to this page. When clicking the button, the event handler is only getting called if the FilePath is in the url (default.aspx).

To be more clear:

whatever.com/default.aspx <------ The event handler gets called when the button is clicked

whatever.com <------ event handler is not getting called when button is clicked.

I should note, this page doesn't have much on it. No jquery files included, no javascript, nothing besides a DropDownList and this Button. The Web.Config doesn't have much in it either, at least nothing I can see that would have any impact on this.

<asp:Button ID="btnSelection" OnClick="btnSelection_OnClick" runat="server" Text="Submit" />

protected void btnSelection_OnClick(object sender, EventArgs e)
{
    throw new Exception("Test"); // Only reaches here if /default.aspx is in the url
}

This is probably something small I'm missing. Any guidance would be greatly appreciated.

Check out this link: Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode?

If nothing, it should point you in the right direction.

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