0

我的代码是

Response.Redirect(Server.MapPath("~/ReportPage.aspx"));

4

4 回答 4

3

你不需要MapPath 这里,因为你有相对路径,你可以直接调用Response.Redirect

Response.Redirect("~/ReportPage.aspx");

Server.MapPath将返回给定文件的物理路径。例如,当我们需要读取根文件夹中的 TEXT 文件时

var lines = File.ReadAllLines(Server.MapPath("~/temp.txt"));

但在你的情况下不需要Server.MapPath

于 2013-09-05T09:32:33.973 回答
0

不要使用Server.MapPath.

Response.Redirect("~/ReportPage.aspx");
于 2013-09-05T09:53:13.620 回答
0

你为什么用MapPath这个?重定向由客户端处理,因此无法映射到物理文件。

只需这样做:

Response.Redirect("~/ReportPage.aspx");
于 2013-09-05T09:33:16.220 回答
0

Response.Redirect, 将虚拟路径重定向到一个位置而不是物理路径。而Server.MapPath返回在此上下文中无效的物理路径。

你只需要像这样使用

Response.Redirect("~/ReportPage.aspx");
于 2013-09-05T09:33:42.077 回答