现在得到当前的路径,如:http://community.csdn.net/Expert/PostNew.asp?room=5202我用c#在后台怎么得到:PostNew.asp这个值??

解决方案 »

  1.   

    取"?"和最后一个"/"之间的值

    http://community.csdn.net/Expert/topic/3272/3272535.xml?temp=.6646082
    不要固定了,因为还有可能是jsp,aspx等等
      

  2.   

    string theUrl = http://community.csdn.net/Expert/PostNew.asp?room=5202;
    string[] theParms = theUrl.Split('/');
    string youWant = theParms[theParms.Lengh-1];
      

  3.   

    string theUrl = “http://community.csdn.net/Expert/PostNew.asp?room=5202”;
    string[] theParms = theUrl.Split('/');
    string youWant = theParms[theParms.Lengh-1];
      

  4.   

    this.Request.Url.Segments[2]
    不对,没人给个正解??
      

  5.   

    这么写有怎么不对??
    string str=Page.Request.Url.ToString();

    str.Substring(str.LastIndexOf("/"),str.IndexOf("?"));
      

  6.   

    如果是aspx页面这样做没有错误我已经验证过了,但是如果是asp页面你怎么在后台使用C#?如果将它看成是字符串那么只能使用字符串函数来处理。按照good2000(break)的方法就没有错了!
      

  7.   

    没做出来,不对,不对.谁能给个正解???string str=Page.Request.Url.ToString();

    str.Substring(str.LastIndexOf("/"),str.IndexOf("?"));我这么写不对呀
      

  8.   

    : cuike519(marshal(修练中...)) ( ) 信誉:100 得到的是目录的名
      

  9.   

    string str=Page.Request.Url.ToString();
    str.Substring(str.LastIndexOf("/")+1,str.IndexOf("?")- str.LastIndexOf("/")-1);
      

  10.   

    string theUrl = “http://community.csdn.net/Expert/PostNew.asp?room=5202”;
    //string[] theParms = theUrl.Split('/');
    //string youWant = theParms[theParms.Lengh-1];
    string youWant1 =therul.Substring(therul.LastIndexOf("\\")+1);//PostNew.asp
    string youWant2 =therul.Substring(therul.LastIndexOf(".")+1);//.asp