我的的url地址是:http://localhost:6000/Pagination.aspx?currentPage=15
用Request.Url.AbsoluteUri ,结果是:http://localhost:6000/Pagination.aspx?currentPage=15
可我只想取到?之前的内容,就是想得到:http://localhost:6000/Pagination.aspx
应该怎么做呢,是要用到正则吗,请教大家,最好写上语句,只写大概说明我怕弄不懂哦
用Request.Url.AbsoluteUri ,结果是:http://localhost:6000/Pagination.aspx?currentPage=15
可我只想取到?之前的内容,就是想得到:http://localhost:6000/Pagination.aspx
应该怎么做呢,是要用到正则吗,请教大家,最好写上语句,只写大概说明我怕弄不懂哦
解决方案 »
- 对事务处理的应用,大家是如何设计的
- 动态创建表格、文本框、标签控件和定位的问题
- 请问:在asp,net中的Response.Redirect()事件,如何控制新打开页面的状态呢?
- ASP.NET中怎样把SqlDataReader的结果循环写入/传入Javascript的一个数组中?????? 在线等了一天了啊!!
- 大家帮忙介绍个好的“网址导航”程序
- 在存储过程中使用临时表?
- asp.net技术版的“收藏此页”坏了不能用,一点击就出现“/”应用程序中的服务器错误。请修一下吧!(应该不是我机器的毛病吧)
- 菜鸟问题:命名空间可以重复吗?
- Windows有什么验证Windows用户名、网域、密码的接口吗?
- 不能启动调试模式,高手赐招
- VS创建"服务"的一个错误提示,请大师指点
- 如何获取动态生成的Gridview的单元格的值
string oldValue = "?currentPage=";
if (Request["currentPage"] != null && Request["currentPage"] != "")
{
oldValue += Request["currentPage"].ToString().Trim();
}
url.Replace(oldValue, "");
我是楼主,我用上面的方法试了,单步调试,最后一步之前,oldValue的值已经等于?currentPage=15了,但执行完最后一句,
url的值还是http://localhost:6000/Pagination.aspx?currentPage=15
就好像Replace方法没起作用,为啥呢
该写成string oldValue = @"?currentPage=";
最后一个问题了,@"?currentPage="里是哪个字符得用@搞一下呢,说了给分
这就 ok 啦
string oldValue = @"?currentPage=15";
url.Replace(oldValue, "");
我是楼主,又不对了,用上面这个也替换不了,还是等高手吧,晕了
替换的问题不管了,
string url = @"http://localhost:6000/Pagination.aspx?currentPage=15"; url = s.Substring(0, s.LastIndexOf('?'));
string url = @"http://localhost:6000/Pagination.aspx?currentPage=15"; url = url.Substring(0, s.LastIndexOf('?'));
http://hi.baidu.com/singsue/blog/item/7a7507176d54ee044b90a702.html
这么简单,搜索就有了嘛