比如我有请求地址
/product/list.aspx?id=1
那我怎么来判断当前网站中是否存在/product/list.aspx呢谢谢

解决方案 »

  1.   

    request.filepath得到虚拟路径,然后File.Exists(request.Applicationpath + request.filepath)
      

  2.   

    /*
    -------------------------------------------------------------
    作者:hackztx   [别急→慢慢来→总会好的]
    日期:2008-07-14 14:55:59
    参数:None
    简介:C# URL
    -------------------------------------------------------------
    */
    string str=Request.Url.AbsoluteUri;
    Response.Write(str.Contains("localhost"));
      

  3.   

    使用 httpHandler 或 httpModule 技术
      

  4.   

    不明白你要做什么功能
    如果是找物理路径
    string path=String.Empty;
    try
    {
      path=HttpContext.Current.Server.MapPath("/product/list.aspx");
    }
    catch
    {}
    if(path!=String.Empty)
    {
      Resoponse.Write("Exist This Page!");
    }
    else
    {
      Resoponse.Write("Not Exist This Page!");
    }
      

  5.   

    如我在Global中 protected void Application_BeginRequest(Object sender, EventArgs e)
     {
         string RawUrl = HttpContext.Current.Request.RawUrl;
     }然后我要用最好的性能判断出RawUrl到低在我的网站中是否存在着这个网页
    如果不存在我再对他进行转写
    如传入URL
    /Product/ProductList.aspx?ID=2
    网站中有这个文件那就链接到
    /Product/ProductList.aspx?ID=2如传入URL
    /Product/2.aspx
    网页中没有这个文件,那么URL转到
    /Product/ProductView.aspx?ID=2
      

  6.   

    获得用户请求的URL
    string RawUrl = HttpContext.Current.Request.RawUrl;经过字符串的处理查看是否存在该页面
    File.Exists(filePath)
      

  7.   

    我觉得根据虚拟路径获取物理文件的路径来判断文件是否存在就很简单了= =#想不到更简单的了...难道直接去访问那个页面catch出来= =?,俄貌似这样更恶心哦