日期:2014-05-17  浏览次数:20516 次

关于“不是有效的虚拟路径”问题请教
WebRequest req = HttpWebRequest.Create(TextBox1.Text);
  req.Method = "GET";
  req.Credentials = CredentialCache.DefaultCredentials;
  req.ContentType = "application/x-www-form-urlencoded";
  HttpWebResponse wr = (HttpWebResponse)req.GetResponse();
  string bb = Server.MapPath("http://zky/yztoy/bb.aspx");
  string htmlPage = UrlMapping.AspxToHtml(req.RequestUri.ToString());
  string htmlFile = Server.MapPath(htmlPage);
  if (File.Exists(htmlFile))
  {
  return;
  }

上述代码中运行到string bb = Server.MapPath("http://zky/yztoy/bb.aspx");
这句时总提示“http:/zky/yztoy/bb.aspx”不是有效的虚拟路径,请问为什么呢?注意是http:/,而不是http://

------解决方案--------------------
string bb = Server.MapPath("/bb.aspx");//在MapPath()不能填写绝对路径,只能填写相对路径