使用 ASP.NET 身份验证/授权与 Cassini 开发服务器
我刚刚遇到了在 VS 中使用集成开发服务器(Cassini)的问题之一,想看看是否有任何解决方案。
我们使用 asp.net 身份验证来保护站点。但是,Cassini 以集成管道模式运行,这意味着对所有文件的请求都通过 asp.net isapi。这样做的结果是它保护了在生产环境中无法保护的文件(.htm .js .css 等)。
现在我知道我们可以在本地 IIS 实例上运行该项目,但我们希望尽可能避免这种情况。但是,由于上述问题,这看起来是唯一的解决方案。
有人知道如何让 Cassini 使用身份验证吗?准备好后可以轻松地将其转移到生产环境中。 (我还想避免使用专门允许访问这些文件的不同开发 web.config)。
顺便说一下,我们使用的是VS2010。
非常感谢。
I've just run into one of the problems of using the integrated dev server (Cassini) in VS and would like to see if there are any solutions.
We're using asp.net authentication to secure the site. However, Cassini runs in integrated pipeline mode, meaning that requests for all files go through the asp.net isapi. The result of this is that it's securing files that would otherwise not be secured in a production environment (.htm .js .css etc..).
Now I understand that we can run the project on a local IIS instance, but we would like to avoid this if possible. But, because of the problem above, this is looking like the only solution.
Does anybody have any ideas about how to get Cassini working with authentication that can be easily moved to a production environment when ready. (I'd also like to avoid having a different development web.config that specifically allows access to these files).
We're using VS2010 by the way.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了使用 Cassini,您还可以下载并安装 IIS Express:
Instead of using Cassini, you can download and install IIS Express:
您可以连接到 global.asax 或
IHttpModule
中的HttpApplication.PostAuthenticateRequest
事件。 MSDN 上的 PostAuthenticateRequest 事件在事件处理程序中,检查您想要不安全的文件扩展名。如果文件扩展名匹配,则将
HttpContext.User
设置为IPrincipal
实例,该实例具有访问指定目录中的文件所需的角色。You can wire up to the
HttpApplication.PostAuthenticateRequest
event in your global.asax or anIHttpModule
. PostAuthenticateRequest event on MSDNIn the event handler, check the file extension for the one that you want to be unsecured. If the file extension is a match then give set the
HttpContext.User
to anIPrincipal
instance that has the roles required for accessing a file in the specified directory.