【问题标题】:Response.redirect puts extra characters in the url Error 400Response.redirect 将额外的字符放入 url 错误 400
【发布时间】:2010-06-23 20:30:22
【问题描述】:

我正在尝试在按钮单击事件服务器端使用 response.redirect,但它给了我 http 400 错误请求错误。我之前没有收到此错误,但我只是将项目移至 vs 2010 框架 4.0,然后我开始收到此错误。 这就是我要写的:

 protected void bOrganizationAddID_Click(object sender, EventArgs e)
    {
        string MyURL;
        MyURL = "addNewPopup.aspx?orgID=" + this.OrganizationID;

        Response.Redirect(MyURL);



    }

当我尝试构建它时,页面上显示的错误网址是: http://localhost:2504/padrap/pages/admin/%2fpadrap%2fpages%2fadmin%2faddNewPopup.aspx%3forgID%3d33

而不仅仅是: localhost:2504/padrap/pages/admin/addNewPopup.aspx?orgID=33

谁能帮帮我。如何获得重定向以将我带到正确的网址? 谢谢!

【问题讨论】:

    标签: asp.net response.redirect


    【解决方案1】:

    try--Server.UrlEncode(this.OrganizationID)

    【讨论】:

      【解决方案2】:

      所以,我认为这是 4.0 或其他版本中的错误,因为我尝试了所有方法。解决方法是这样的:

      ScriptManager.RegisterStartupScript(this, this.GetType(), 
                 "redirectFixOrg", string.Format("document.location = '{0}?orgID={1}'",
                 this.ResolveClientUrl("~/pages/admin/addNewPopup.aspx"), this.OrganizationID), true);
      

      这对我有用,但我不知道为什么 response.redirect 不起作用。

      谢谢!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-03-31
        • 2014-04-18
        • 2020-03-28
        • 1970-01-01
        • 2015-12-02
        • 1970-01-01
        • 2013-09-06
        • 2021-01-04
        相关资源
        最近更新 更多