5的表单身份验证

5的表单身份验证

本文介绍了MVC 4 Authorize属性无法识别来自ASP.Net 3.5的表单身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为以前为其创建ASP.Net 3.5(VS 2008)应用程序的客户端创建一个新的MVC 4应用程序.我创建了一个网关应用程序来启动其他ASP.Net 3.5 Web应用程序,该网关应用程序处理登录名和表单身份验证票证.

I am creating a new MVC 4 app for a client that I had previously created ASP.Net 3.5 (VS 2008) apps for. I created a gateway app to launch several other ASP.Net 3.5 web apps, with the gateway app handling the login and the forms authentication ticket.

只要所有其他Web应用程序对表单身份验证和机器密钥部分具有相同的设置,所有其他应用程序都可以使用表单身份验证对象来查看用户是否已通过身份验证.

As long as all of the other web apps have the same settings for the forms authentication and machine key sections all other apps were able to use the forms auth objects to see if the user was authenticated.

我现在正在使用IIS 5.x在XP开发箱上使用VS 2010中的相同表单身份验证设置创建一个新的MVC 4应用程序. (我必须这样做)问题是网关应用程序可以正常运行MVC应用程序,而无需登录.但是,如果我将Authorize属性添加到初始控制器,则MVC应用将转到登录名,然后按预期启动页面,但是到MVC应用程序的链接将直接回到网关登录页面.

I am now creating a new MVC 4 app using the same forms authentication settings in VS 2010 on an XP development box using IIS 5.x. (I have to do this) The problem is that the gateway app launches the MVC app fine with no login; however, if I add the Authorize attribute to initial controller the MVC app goes to the login and then the launch page as expected, however the link to the MVC app goes right back to the gateway login page.

这是Web配置部分

<authentication mode="Forms">   <forms
        slidingExpiration="true"
        timeout="3"
        loginUrl="http://localhost/MYGateway/Login.aspx"
        path="/"
        name=".PGSA"
        protection="All"
        defaultUrl="http://localhost/MYGateway/home.aspx"
        >
  </forms>
<machineKey   validationKey="C5123C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" decryptionKey="8A9BE8FD67AF6979E7D29998CFEA50DD3D3799C77AF2B72F"   validation="SHA1"   decryption="3DES"    />

任何帮助将不胜感激谢谢,保罗

Any help would be appreciatedThanks,Paul

推荐答案

由于James H

I was finally able to get this solved, thanks to this question's second answer by James H Upgrading to ASP.NET 4.5/MVC 4 forms authentication fails

诀窍是这个

<system.web>
 <machineKey compatibilityMode="Framework20SP2" />
</system.web>

这篇关于MVC 4 Authorize属性无法识别来自ASP.Net 3.5的表单身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 15:04