发送Response.StatusCode后的Response.Redirect问题

时间:2014-01-08 19:34:42

标签: asp.net .net-4.0 iis-7.5

我有一个客户404错误页面设置(.aspx),当它被服务器执行时,我通过后面的代码发送Response.StatusCode = 404。页面正确加载正确的信息,页眉,页脚等。但是,如果单击,页眉或页脚中的控件会执行Response.Redirect。因此,如果在404页面上单击它们,则除了将一个查询字符串添加到URL之外没有任何反应 http://stage.mysite.com/defaudlt.aspx?404%3bhttp%3a%2f%2fstage.mysite.com%3a80%2fdefaudlt.aspx

我有一种预感,这与已发送的标题有关,但不确定如何修复。

*编辑添加代码

404 Page CS

protected void Page_Load(object sender, EventArgs e)
{
    Response.Clear();      
    Response.StatusCode = 404;
}

母版页中的渲染按钮

<input type="submit" class="wtb-submit" id="ctl00_ctl00_ctl00_ContentMain_Button1" value="WHERE TO BUY" name="ctl00$ctl00$ctl00$ContentMain$Button1">

MasterPage按钮点击事件

 protected void btnLocator_Click(object sender, EventArgs e)
{

    Response.Redirect("/locator/default.aspx");

}

1 个答案:

答案 0 :(得分:0)

你可以在你的页面之前使用〜唱歌

 Response.Redirect("~/locator/default.aspx");

希望这会有用

相关问题