如何在iis6上的ASP.NET MVC中为单个路由设置Windows身份验证?

发布于 2024-07-12 03:46:04 字数 927 浏览 3 评论 0原文

我正在开发一个网络应用程序,我需要混合表单和表单。 Windows 身份验证一起。

我选择的方法是这样的:所有网站上的身份验证方法都必须是表单身份验证。 有一个表单页面(~/home/Login)可以通过表单身份验证登录。 神奇(也是麻烦)的是,只有一个页面(例如 ~/Home/WinLogin)必须将身份验证方法设置为 Windows 身份验证。 该页面用于读取HttpContext.User.Identity.Name来获取windows用户名。

我不知道如何在 iis6 上为某一特定路由设置 win 身份验证?

该路由看起来像 ~/Home.ashx/WinLogin。 好吧,但是然后呢? 我尝试在虚拟目录和子目录WinLogin中创建一个目录Home.ashx。 但随后 ~/Home.ashx/Login (带有登录表单)停止工作。

因为在 iis6 上我们必须使用 ashx 处理程序,所以除了创建一个普通的网页 ~/WinLogin.aspx 来完成这项工作之外,似乎没有其他方法可以做到这一点。 然而我想避免这种情况并只使用 MVC。

只是为了了解如何设置 iis7: IIS 7.0 服务器端博客 它并不完美(Mike Volodarsky 必须创建自定义表单身份验证模块),但它可以工作。

I'm developing a web application and I need to mix Forms & Windows authentication together.

The approach which I selected is this: authentication method on all the web site has to be forms auth. There is a form page (~/home/Login) to login in via forms auth. The magic (and trouble) is that only one page (say ~/Home/WinLogin) has to have auth metod set up to be windows auth. This page is used to read HttpContext.User.Identity.Name to get the windows user name.

What I don't know is how to set up the win auth on iis6 for the one particular route?

The route looks like ~/Home.ashx/WinLogin. Ok, but what then? I tried to create a directory Home.ashx in the virtual directory and subdirectory WinLogin. But then ~/Home.ashx/Login (with the login form) stopped working.

Because on iis6 we have to use a ashx handler it seems that there is no other way how to do it instead of creating a ordinary web page ~/WinLogin.aspx that does the work. However I wanted to avoid that and use MVC only.

Just for info how to setup iis7: IIS 7.0 Server-Side blog
It's not perfect (Mike Volodarsky had to create custom forms auth module), but it works.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉栀 2024-07-19 03:46:04

您无法像在 IIS7 中那样在 IIS6 中选择性地设置 Windows 身份验证。 不过,您可以将 home.ashx 设置为支持匿名和 Windows 身份验证; 替换 /Login 情况下的 HttpContext.User 属性,并在 /WinLogin 情况下使用 windows 原理。 但是,您需要小心,您的代码路径允许您希望他们使用表单身份验证但他们向您提供 Windows 原则身份并忽略它的情况。

You can't selectively set windows auth in IIS6 like you can in IIS7. You could however set the home.ashx to support anonymous and windows auth; replace the HttpContext.User property in the /Login case and use the windows principle in the /WinLogin case. However, you need to be careful that your code path allows for the case where you want them to use forms auth but they're presenting you with a windows principle identity and ignore that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文