为什么我不能重写URL?

xboard 2005-01-24 01:35:29
context.RewritePath(sendToUrlLessQString, String.Empty, queryString)

sendToUrlLessQString="/Forums/default.aspx"
queryString="ForumGroupID=2"

结果竟然不能重写URL,我想重写为"/Forums/default.aspx?ForumGroupID=2"
二个值都传递正确,为什么就不行呢。我已经配置了ihttpmodule接口

有谁知道原因?
...全文
178 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xboard 2005-01-24
  • 打赏
  • 举报
回复
好的。我先试度看。
zpisgod 2005-01-24
  • 打赏
  • 举报
回复
我是说先不要管政则,无论请求什么都重写到一个已知的页面去,看看urlrewrite到底能不能用
zpisgod 2005-01-24
  • 打赏
  • 举报
回复
跳转到其他页面试试
xboard 2005-01-24
  • 打赏
  • 举报
回复
已经匹配了。

context.RewritePath(sendToUrlLessQString, String.Empty, queryString)

sendToUrlLessQString="/Forums/default.aspx"
queryString="ForumGroupID=2"
zpisgod 2005-01-24
  • 打赏
  • 举报
回复
在工作嘛~~

确定你的政则表达式正确匹配了吗?
xboard 2005-01-24
  • 打赏
  • 举报
回复
不在了、
xboard 2005-01-24
  • 打赏
  • 举报
回复
可是问题的我需要显示http://localhost/Forums/default.aspx?ForumGroupID=2的内容。
而不是http://localhost/forums的内容

请求url为http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx
需要重写为http://localhost/Forums/default.aspx?ForumGroupID=2 (这个是需要显示的内容)
结果停留在http://localhost/forums (结果还是显示首页的内容)

我是要首页http://localhost/forums 点击链接http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx 。结果它还是显示首页的内容
zpisgod 2005-01-24
  • 打赏
  • 举报
回复
地址栏显示http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx

而内容是http://localhost/forums,这不说明重写成功了吗?
xboard 2005-01-24
  • 打赏
  • 举报
回复
就像你所说。但问题

地址栏显示http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx


但显示的内容还是http://localhost/forums的内容而已
zpisgod 2005-01-24
  • 打赏
  • 举报
回复
怎么会跳转到http://localhost/forums了呢,不太明白

如果重写成功的话
请求url为http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx
地址栏会仍会显示http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx
只是显示的页面是
http://localhost/Forums/default.aspx?ForumGroupID=2 的内容
如果不成功则显示为http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx的内容
xboard 2005-01-24
  • 打赏
  • 举报
回复
请求url为http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx
需要重写为http://localhost/Forums/default.aspx?ForumGroupID=2
结果停留在http://localhost/forums

是这个意思吗??

是的,就是这个意思,呵呵
zpisgod 2005-01-24
  • 打赏
  • 举报
回复
请求url为http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx
需要重写为http://localhost/Forums、default.aspx?ForumGroupID=2
结果停留在http://localhost/forums

是这个意思吗??
xboard 2005-01-24
  • 打赏
  • 举报
回复
没有错误。它就是不会转到URL

比如。我当前的http://localhost/Forums/ForumGroupID/2/ForumGroup.aspx

需要重写为http://localhost/Forums、default.aspx?ForumGroupID=2
用正则表达式。各个匹配。
sendToUrlLessQString="/Forums/default.aspx"
queryString="ForumGroupID=2"

context.RewritePath(sendToUrlLessQString, String.Empty, queryString)

结果重写之后URL还是停要首页http://localhost/forums。没有真正URL

zpisgod 2005-01-24
  • 打赏
  • 举报
回复
出了什么错误吗???

62,075

社区成员

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

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

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

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