首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

关于“不是有效的虚拟路径”有关问题请问

2012-07-16 
关于“不是有效的虚拟路径”问题请教WebRequest req HttpWebRequest.Create(TextBox1.Text)req.Method

关于“不是有效的虚拟路径”问题请教
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()不能填写绝对路径,只能填写相对路径

热点排行