我有一个从jQuery Post方法调用的aspx页面(webforms)(它工作正常),但是来自后面的代码的Response.Redirect方法确实不要使用重定向的URL重新加载浏览器。但是,它实际上确实会触发该网址。 我很确定这与jQuery调用的页面有关,但不知道为什么会发生这种行为。asp.net response.redirect命中url,但没有改变浏览器页面
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
//lid = Validation.StripToGUID(ObjToGUID(Request.QueryString("lid")))
lid = Validation.StripToGUID(ObjToGUID(Request.Form["lid"]));
string sid = null;
if (lid.Length == 36)
{
//retrieve the link (and product data) from the database
LiveItem_Data.DBConnStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
LiveItem o = new LiveItem();
o = LiveItem_Data.GetLive_ItemFromLID(lid);
if (HTTPStuff.RemoteFileExists(o.product_link))
{
Response.Redirect(o.product_link, true);
}
else
{
//generate an error
}
}
}
}
我通过代码加强和product_link工作(手动剪切并粘贴到浏览器),和远程页面被称为(我测试使用具有记录其他网站的链接)。 然而浏览器并未打开(尝试过FF,IE,Opera,Chrome)新的URL。
jQuery的岗位:
$('.popInfoHG').click(function() {
var ListID = $(this).parent().find('[id*=hidlid]').val();
$.post("redir.aspx", { lid: ListID });
});
我核实,HTTPredirect功能在IIS快速打开(从Visual Studio 2012)。难倒!
为什么你为'Response.Redirect(o.product_link,true)保留'true';' –
要结束响应,但false也不起作用。 – MC9000