IIS 日志文件显示重写而不是原始 URL
我遇到了一个问题,因为更改在 Asp.Net 应用程序中执行 URL 重写的方式已更改了 IIS 日志文件,使其不再如下所示:
/page/80 等。 /page/anotherpage/ 80 等...
到
default.aspx page=1 80 等... default.aspx page=2 80 等等...
我有点困惑这是怎么发生的。 是否缺少一个设置(Win 2008,ASP.NET 2.0) 中的“runAllManagedRequests”设置也已打开。
I've got a problem in that changing the way I'm doing Url Rewriting in an Asp.Net application has changed the IIS log files from looking like this:
/page/ 80 etc..
/page/anotherpage/ 80 etc...
to
default.aspx page=1 80 etc...
default.aspx page=2 80 etc...
I'm a bit stumped as to how this happened. Is there a setting I'm missing (Win 2008, ASP.NET 2.0) The 'runAllManagedRequests' setting in the has also been switched on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
URL 重写是由模块完成的吗? 如果是,则重写模块可能在日志记录模块之前运行。 您可以更改模块在 IIS 管理器中运行的顺序。 进入 IIS 管理器中的模块并选择查看有序列表...; 然后您可以按照您想要的顺序上下移动模块。
Is the URL rewriting being done by a module? If it is, then it's possible the rewriting module is running before the logging module. You can change the order that modules run in IIS Manager. Go into Modules in IIS Manager and select View Ordered List...; then you can move modules up and down into the order you want.
我不知道您使用什么方法重写 URL,但我知道使用 Apache(以及 Windows 上的 ISAPI_Rewrite),您必须向 .htaccess 文件(或等效文件)中的每个规则添加一个标志,以告诉它记录重写后的 URL 而不是原始 URL。
I don't know what method you are using to rewrite the URLs, but I know that with Apache (and ISAPI_Rewrite on Windows) you have to add a flag to each rule in the .htaccess file (or equivalent) to tell it to log the rewritten URL and not the original.
据我所知,这是设计使然,因为 IIS 只接收重写的 URL,而不是原始的,因为重写的 URL 被发送到 .Net 应用程序及其进行转换的应用程序。
As far as i am aware this will be by design as IIS only ever recives the rewritten URL not the orignal, as the rewritten url is sent to the .Net appliction and its the appliction that dose the converting.
这个问题是重复。
我也遇到过同样的问题。 解决此问题的一种方法是使用 Server.Transfer 而不是 Context.RewritePath。 Server.Transfer 不会重新启动整个页面生命周期,因此原始 URL 仍将被记录。 请务必为“preserveForm”参数传递“true”,以便 QueryString 和 Form 集合可用于第二页。
This question is a duplicate.
I've had exactly the same problem. One way around this is to use Server.Transfer instead of Context.RewritePath. Server.Transfer doesn't restart the entire page lifecycle so the original URL will still be logged. Be sure to pass "true" for the "preserveForm" parameter so that the QueryString and Form collections are available to the 2nd page.