UrlRewriting.Net 模块 + IIS7 等于 Page.User == null? [英] UrlRewriting.Net Module + IIS7 Equals Page.User == null?

查看:12
本文介绍了UrlRewriting.Net 模块 + IIS7 等于 Page.User == null?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 UrlRewriting.Net 模块几年了,在 Windows XP 和 Windows 2003 中都没有出现任何问题.我最近刚刚将我的家用 PC 升级到了 Windows 7 并开始开发一个新网站.

I've used the UrlRewriting.Net module for a couple years now without any problems in Windows XP and Windows 2003. I just recently upgraded my home PC to Windows 7 and started developing a new website.

计划是使用 .html 扩展名并使用 UrlRewriting.Net 模块将它们重写为对应的 .aspx 扩展名.一切在 VWD 2008 中都能完美运行,但是当我尝试通过 IIS7 运行它时,情况就不同了.

The plan was to use .html extensions and rewrite them to their .aspx counterparts using the UrlRewriting.Net module. Everything works flawlessly in VWD 2008, but when I try running it through IIS7 it is a different story.

当我尝试通过 .html 重写访问页面时,我无法再访问 Page.User;它不断返回空值.如果我使用它的 .aspx 扩展名点击页面,则正确填充了 Page.User.我还应该提到,我的母版页中有一个 LoginView 控制器,它有同样的症状:通过 .html 扩展名访问时,它显示 AnonyousTemplate;使用 .aspx 扩展名时,它会正确显示 LoggedInTemplate.我猜这两者是相关的.

When I try to access a page via the .html rewrite I can no longer access Page.User; it keeps returning null. If I hit the page using it's .aspx extension, Page.User is correctly populated. I should also mention that I have a LoginView controller in my Master Page and it suffers from the same symptoms: When accessing via .html extension it shows the AnonyousTemplate; When using .aspx extension it properly shows the LoggedInTemplate. I'm guessing the two are related.

[注意:我也尝试过无扩展名的 URL,它们也出现了同样的问题]

[Note: I've also tried extensionless URLs and they exhibit the same problem]

我让它工作的唯一方法是将应用程序池切换到经典,然后需要我为 .html 扩展添加一个 ASP.Net ddl 处理程序 [否则它由 StaticFileHandler 处理并出现作为 404 错误].但是,我希望我的 Web 应用程序能够为人们正常运行,而不必摆弄 IIS.

The only way I've gotten it to work is to switch the application pool to Classic, which then requires me to add an ASP.Net ddl handler for the .html extension [otherwise it is handled by the StaticFileHandler and comes up as a 404 error]. However, I'd like my web app to run properly for people without having to fiddle around with IIS.

所以我有几个问题:

  • 有没有人知道为什么 Page.User 对于 .html => .aspx 重写的页面总是等于 null?
  • 为什么它可以在 VWD 2008 中运行,而不能在 IIS7 中运行?
  • IIS6 => IIS7 的哪些变化可能导致了这种情况?
  • 对解决方法还有其他想法吗?

[注意:我刚刚尝试了 .aspx => .aspx 重写,但没有出现问题.不是我想要的,但我想我应该提一下.]

[Note: I just tried a .aspx => .aspx rewrite and it did not exhibit the problem. Not really what I want, but thought I should mention it.]

推荐答案

UrlRewriting.Net 模块刚刚取得突破.这使它在 IIS7 中的集成模式下工作:

Just had a breakthrough with the UrlRewriting.Net module. This makes it work in Integrated Mode in IIS7:

搞清楚之后,我搜索了runAllManagedModulesForAllRequests",弹出的第一件事是Scott Guthrie 的博客,实际上讨论了为此目的使用它.

After figuring it out I did a search on "runAllManagedModulesForAllRequests" and the first thing that popped up was Scott Guthrie's blog which actually talks about using it for this purpose.

这篇关于UrlRewriting.Net 模块 + IIS7 等于 Page.User == null?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆