【发布时间】:2011-11-05 21:36:02
【问题描述】:
如果我浏览到http://localhost/edumatic3/trunk/login/accesscode/Default.aspx,我的回发工作。但是,如果我浏览到 http://localhost/edumatic3/trunk/login/accesscode/(将 Default.aspx 定义为默认文档),我的回发将不起作用。
有没有办法让它工作?或者我应该删除默认文档并强制用户浏览到http://localhost/edumatic3/trunk/login/accesscode/default.aspx?
更新:
代码(部分):
<div id="continueDiv">
<asp:ImageButton ID="continueImageButton"
runat="server" ValidationGroup="continue"
OnClick="ContinueImageButton_Click"
AlternateText="<%$ Resources:login, continue_alternatetext %>"/>
</div>
后面的代码(部分):
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)
{
....
当我点击ImageButton时,Page_Load被触发,IsPostBack为假...正常情况下应该为真。根本没有触发 ContinueImageButton_Click(...)。
在 HTML 中(部分):
<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请求:
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...
【问题讨论】:
-
您能否提供您的 default.aspx 文件的代码,回发不起作用的事实是该文件正在使用 head 请求而不是 get 或 post 请求进行重定向。这就是为什么它不起作用。
-
完成。如果我查看 Charles(http 嗅探器),我可以看到正在向服务器发送 POST。
-
当你说你的回发“不起作用”时,你到底是什么意思?您可能想在代码隐藏中放置一些断点并使用调试器运行以查看到底发生了什么。
-
如果您在页面未按预期运行时遇到问题,您可能会在页面中包含您的代码隐藏。
-
只是为了看看它是否有所作为,把 CausesValidation="false" 放在你的按钮上,看看它是否改变了什么。