问个简单的问题,在线结贴

good2000 2004-08-16 02:36:25
现在得到当前的路径,如:http://community.csdn.net/Expert/PostNew.asp?room=5202

我用c#在后台怎么得到:PostNew.asp这个值??
...全文
241 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
jingqiu5 2005-04-02
  • 打赏
  • 举报
回复
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
luerming 2004-08-16
  • 打赏
  • 举报
回复
string str=Page.Request.Url.ToString();
str.Substring(str.LastIndexOf("/")+1,str.IndexOf("?")- str.LastIndexOf("/")-1);
good2000 2004-08-16
  • 打赏
  • 举报
回复
: cuike519(marshal(修练中...)) ( ) 信誉:100 得到的是目录的名
good2000 2004-08-16
  • 打赏
  • 举报
回复
没做出来,不对,不对.谁能给个正解???

string str=Page.Request.Url.ToString();

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

我这么写不对呀
cuike519 2004-08-16
  • 打赏
  • 举报
回复
如果是aspx页面这样做没有错误我已经验证过了,但是如果是asp页面你怎么在后台使用C#?如果将它看成是字符串那么只能使用字符串函数来处理。按照good2000(break)的方法就没有错了!
good2000 2004-08-16
  • 打赏
  • 举报
回复
这么写有怎么不对??


string str=Page.Request.Url.ToString();

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

good2000 2004-08-16
  • 打赏
  • 举报
回复
this.Request.Url.Segments[2]
不对,

没人给个正解??
wnlovezxm 2004-08-16
  • 打赏
  • 举报
回复
string theUrl = “http://community.csdn.net/Expert/PostNew.asp?room=5202”;
string[] theParms = theUrl.Split('/');
string youWant = theParms[theParms.Lengh-1];
wnlovezxm 2004-08-16
  • 打赏
  • 举报
回复
不想要参数就从“?”开始把字符串截了!
wnlovezxm 2004-08-16
  • 打赏
  • 举报
回复
string theUrl = http://community.csdn.net/Expert/PostNew.asp?room=5202;
string[] theParms = theUrl.Split('/');
string youWant = theParms[theParms.Lengh-1];
rickjelly2004 2004-08-16
  • 打赏
  • 举报
回复
Request.Url.Segments(2)
cuike519 2004-08-16
  • 打赏
  • 举报
回复
this.Request.Url.Segments[2]
wangsaokui 2004-08-16
  • 打赏
  • 举报
回复
取"?"和最后一个"/"之间的值

http://community.csdn.net/Expert/topic/3272/3272535.xml?temp=.6646082
不要固定了,因为还有可能是jsp,aspx等等
splark 2004-08-16
  • 打赏
  • 举报
回复
没这么简单吧,那只是举个例子
Eddie005 2004-08-16
  • 打赏
  • 举报
回复
用string.Substring()吧

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧