Response.Redirect的URL查询字符串与错误
问题描述:
我得到“资源无法找到”使用下列URL Response.Redirect的错误。如果我使用Response.Redirect(“〜/ Orders/ViewOrders.aspx”),它工作正常。什么可能是错的?感谢您的任何建议。Response.Redirect的URL查询字符串与错误
这里是URL字符串的输出。
〜/订单/ ViewOrders.aspx URL =? 'HTTP://servername/Reports/Pages/ReportViewer.aspx /测试/ test_orders & RS:命令=渲染'
这里是我的代码。
string url = string.Format(“〜/ Orders/ViewOrders.aspx?url ='{0}'”,editItem.Cells [14] .Text); Response.Redirect(url);
答
您需要查询字符串
string url = string.Format("~/Orders/ViewOrders.aspx?url={0}"
, Server.UrlEncode(editItem.Cells[14].Text));
Response.Redirect(url);
另外,我不认为你应该有那些单引号进行编码。我删除了它们。
谢谢。 Server.UrlEncode做了诡计。 – nav100 2012-02-21 20:56:46