I have a webapplication, that I have running in the WAN as well as in the LAN. The same code runs in separate web apps. In the WAN I have configured it to use forms authentication. It works seamlessly. However the LAN app is configured to use windows authentication.
我有一个web应用程序,我已经在WAN和LAN中运行。相同的代码在单独的Web应用程序中运行。在WAN中,我已将其配置为使用表单身份验证。它无缝地工作。但是,LAN应用程序配置为使用Windows身份验证。
What happens now, is that the website says "Hello DOMAIN\TestUser" which shows, that
现在发生了什么,是网站上写着“Hello DOMAIN \ TestUser”,它表明了这一点
- Request.IsAuthenticated must be true
- Request.IsAuthenticated必须是真的
- User.Identity.Name is set to the correct user
- User.Identity.Name设置为正确的用户
However: I'm always finding myself on the "Account/Login" page. For clarification: my Login page is using a general layout-template that performs the 'Request.IsAuthenticated' mentioned above.
但是:我总是发现自己处于“帐户/登录”页面。为了澄清:我的登录页面使用的是一般布局模板,用于执行上面提到的'Request.IsAuthenticated'。
My question: Why am I being redirected to the login page, when the authentication evidently succeeded? And what do I do to make it work? :)
我的问题:当身份验证显然成功时,为什么我被重定向到登录页面?我该怎么做才能让它发挥作用? :)
This, I guess is the crucial part of my configuration:
我想这是我配置的关键部分:
<system.web>
<authentication mode="Windows">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<membership defaultProvider="SimpleMembershipProvider">
<providers>
<clear />
<add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
</providers>
</membership>
</system.web>
The IIS for this web app is setup with Windows Authentication enabled and all other methods of Authentication disabled.
此Web应用程序的IIS设置为启用Windows身份验证,并禁用所有其他身份验证方法。
(I'm using ASP.Net MVC 4)
(我正在使用ASP.Net MVC 4)
3 个解决方案
#1
1
Encountered this before and have to compare my local IIS deployment, where my project runs just fine, with that of what was deployed on a server. It turns out there are extra DLLs that should not have been deployed. My scenario though is a bit different than yours. The project was working on my local machine but not on a LAN environment. The extra files that needed to be removed:
之前遇到过这种情况,必须将我的项目运行良好的本地IIS部署与服务器上部署的部署进行比较。事实证明,还有一些不应该部署的DLL。我的情况虽然与你的情况略有不同。该项目正在我的本地计算机上工作,但不在LAN环境中。需要删除的额外文件:
- WebMatrix.Data.dll
- WebMatrix.Data.dll
- WebMatrix.WebData.dll
- WebMatrix.WebData.dll
I hope it's the same case as yours, that is one hard deployment issue to catch.
我希望它与你的情况相同,这是一个难以接受的部署问题。
#2
0
Taking out the <forms loginUrl="~/Account/Login" timeout="2880" />
line and the <membership />
section might help?
取出
Which would leave you with:
哪个会让你:
<system.web>
<authentication mode="Windows"></authentication>
</system.web>
#3
0
I found the solution here: http://martinnormark.com/asp-net-mvc-3-windows-authentication-problem-redirects-to-account-login after spending a few more hours googling...
我在这里找到了解决方案:http://martinnormark.com/asp-net-mvc-3-windows-authentication-problem-redirects-to-account-login花了几个小时后谷歌搜索...
The Answer is luckily very simple: Add these two properties to your app settings:
答案很幸运很简单:将这两个属性添加到您的应用设置:
<appSettings>
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
</appSettings>
Looks like very bad practice to me... but hey, it does the job.
对我来说看起来非常糟糕的做法...但是,嘿,它完成了这项工作。
#1
1
Encountered this before and have to compare my local IIS deployment, where my project runs just fine, with that of what was deployed on a server. It turns out there are extra DLLs that should not have been deployed. My scenario though is a bit different than yours. The project was working on my local machine but not on a LAN environment. The extra files that needed to be removed:
之前遇到过这种情况,必须将我的项目运行良好的本地IIS部署与服务器上部署的部署进行比较。事实证明,还有一些不应该部署的DLL。我的情况虽然与你的情况略有不同。该项目正在我的本地计算机上工作,但不在LAN环境中。需要删除的额外文件:
- WebMatrix.Data.dll
- WebMatrix.Data.dll
- WebMatrix.WebData.dll
- WebMatrix.WebData.dll
I hope it's the same case as yours, that is one hard deployment issue to catch.
我希望它与你的情况相同,这是一个难以接受的部署问题。
#2
0
Taking out the <forms loginUrl="~/Account/Login" timeout="2880" />
line and the <membership />
section might help?
取出
Which would leave you with:
哪个会让你:
<system.web>
<authentication mode="Windows"></authentication>
</system.web>
#3
0
I found the solution here: http://martinnormark.com/asp-net-mvc-3-windows-authentication-problem-redirects-to-account-login after spending a few more hours googling...
我在这里找到了解决方案:http://martinnormark.com/asp-net-mvc-3-windows-authentication-problem-redirects-to-account-login花了几个小时后谷歌搜索...
The Answer is luckily very simple: Add these two properties to your app settings:
答案很幸运很简单:将这两个属性添加到您的应用设置:
<appSettings>
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
</appSettings>
Looks like very bad practice to me... but hey, it does the job.
对我来说看起来非常糟糕的做法...但是,嘿,它完成了这项工作。