If I browse to http://localhost/edumatic3/trunk/login/accesscode/Default.aspx, my postback works. However, if I browse to http://localhost/edumatic3/trunk/login/accesscode/ (with Default.aspx defined as default document), my postback doesn't work.
Is there a way to make this work? Or should I remove the default document and force users to browse to http://localhost/edumatic3/trunk/login/accesscode/default.aspx?
UPDATE:
Code (part):
<div id="continueDiv">
<asp:ImageButton ID="continueImageButton"
runat="server" ValidationGroup="continue"
OnClick="ContinueImageButton_Click"
AlternateText="<%$ Resources:login, continue_alternatetext %>"/>
</div>
Code behind (part):
protected void Page_Load(object sender, EventArgs e)
{
Log.Debug("Page_Load(...)");
Log.Debug("Page_Load(...) :: PostBack = " + IsPostBack);
if (!IsPostBack)
{
continueImageButton.ImageUrl = "~/App_Themes/" + base.Theme
+ "/images/" + Resources.login.btn_continue;
}
}
/// <summary>
/// Continue Image Button Click Handler
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ContinueImageButton_Click(object sender, EventArgs e)
{
....
When I click on the ImageButton, Page_Load is triggered, and IsPostBack is false… Normally, it should be true. ContinueImageButton_Click(…) isn't triggered at all.
In HTML (part):
<input type="image" name="ctl00$ContentPlaceHolder1$continueImageButton"
id="ctl00_ContentPlaceHolder1_continueImageButton"
src="../../App_Themes/LoginTedu/images/en_continue.png" alt="Continue"
onclick="javascript:WebForm_DoPostBackWithOptions(new
WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$continueImageButton",
"", true, "continue", "", false, false))"
style="border-width:0px;">
Http request:
POST /edumatic3/trunk/login/accesscode/ HTTP/1.1
Host: localhost
Referer: http://localhost/edumatic3/trunk/login/accesscode/
Content-Length: 1351
Cache-Control: max-age=0
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1
(KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: nl,en-US;q=0.8,en;q=0.6,fr;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
ASP.NET_SessionId=33yal3buv310y2etuj33qghg; CurrenUICulture=en-us
__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDw...
Best Answer
I thought I'd try and reproduce this, and you're absolutely right. It breaks without the
default.aspx
with a very simple example that you provided. Looking at the HTML, the reason is fairly clear. It's because the action attribute is empty.A quick search reveled this, ASP.NET 4 Breaking Changes (see Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode).
I've created these two fixes which resolve the issue, use either.
1) Add this code to Global.asax
2) Create a Forms ControlAdapter
Register it by creating this file in App_Browsers\Default.browsers