【发布时间】:2011-10-21 22:47:19
【问题描述】:
单击按钮时,我在 JS 函数中调用了一个 javascript 函数,我重定向到了一个 aspx 页面,在 aspx 页面中我想重定向到另一个页面(这部分不起作用)。 response.redirect 不重定向,只是发回当前页面。知道为什么它不起作用。
这是我的代码:
评论.aspx:
<asp:Button ID="btnComplt" runat="server" Text="Complete" OnClientClick ="return compAsgn()" />
function compAsgn() {
if (window.confirm("Submit all images and complete the assignment?"))
window.location = "SendImages.aspx?insid=" + $("#IAssignmentId").val() + '&option=complete';
else
return false;
SendImages.aspx:
protected void Page_Load(object sender, EventArgs e)
{
assignmentId = Convert.ToInt32(Request.QueryString["insid"]);
string url = "Review.aspx?insid" + assignmentId.ToString() + "&viewOption=review";
string qstrVal = string.Empty;
qstrVal = Request.QueryString["option"].ToString().ToLower();
if (qstrVal != null && qstrVal == "complete")
{
using (ServiceClient client = new Proxies.ServiceRef.ServiceClient())
{
List<AssignmentInfo> ainfo = new List<AssignmentInfo>();
ainfo = client.GetAssignmentInfo(assignmentId);
if (ainfo.Count > 0)
{
if (ainfo[0].UploadedCount == 0)
{
// AfarSessionData class has a property called ProfileId, which is session variable.
if (AfarSessionData.ProfileId == "000000")
url = "Admin.aspx";
else
url = "HomePage.aspx";
}
}
}
}
Response.Redirect(url, false);
}
注意:当我调试时,我确实看到控件点击了 SendImages 页面,但我看到 response.redirect 没有重定向,只是回发到当前页面。
【问题讨论】:
-
使用 fiddler 看看标题怎么说。你应该有一个 302 http 状态。
-
url 在代码中到达该点时的值是多少?
-
Admin.aspx 是 URL 的值
标签: c# asp.net c#-4.0 response.redirect