我如何共享.NET(C#)基于经验证的Web表单和MVC2应用之间的会话? [英] How can I share .net (C#) based authenticated session between web forms and MVC2 applications?

查看:91
本文介绍了我如何共享.NET(C#)基于经验证的Web表单和MVC2应用之间的会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有我们建立在我们使用最新的MVC3和Entity Framework的.NET库可在时间业余时间一个小型应用程序,并部署它。管理层喜欢它,他们希望融入一个沉重的遗产.NET 3.5 Web窗体应用程序。

We have a small application we built in our spare time using the latest mvc3 and Entity Framework .net libraries available at the time, and deployed it. The management liked it, and they want it integrated into a heavy legacy .net 3.5 web forms application.

我需要在这两个应用程序以某种方式使用相同的验证会话。我使用的是相同的数据库及应用认证使用.NET会员和个人资料提供者。这工作得很好,但用户必须分别登录到,即使他们已经为主要的应用程序签署了MVC应用程序。我愿意接受任何建议:在不同的级别,或shared 的饼干等。

I need to somehow use the same authentication sessions across the two applications. I am using the same DB and Application for authentication using the .net membership and profile providers. This works fine, but users have to login separately into the MVC app even when they are already signed in for the main application. I am open to any suggestions: enabling state session at a different level, or shared cookies, etc

什么是绕过此登录要求,我是否应该在MVC应用程序集成到Web表单或保持它作为一个独立的应用程序的最佳方法是什么?我的影响决定主要关注的问题将采取的完全集成,以及应用程序的后期维护的时间。

What is the best way to bypass this login requirement and whether I should integrate the mvc application into the webforms or keep it as an independent application? My main concerns affecting the decision would be time taken for complete integration, and later maintenance of the applications.

推荐答案

首先,事实上,一个应用程序是ASP.NET MVC确实毫无区别就在这里:)

First, the fact one application is ASP.NET MVC does make no difference here :)

二,这里是如何从MSDN做了一个例子:

Second, here is one example of what to do from MSDN:

<一个href=\"http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx\">http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx

从该页面的小片段:

<configuration>
  <system.web>
    <authentication mode="Forms" >
      <!-- The name, protection, and path attributes must match 
           exactly in each Web.config file. -->
      <forms loginUrl="login.aspx"
        name=".ASPXFORMSAUTH" 
        protection="All"  
        path="/" 
        domain="contoso.com" 
        timeout="30" />
    </authentication>

    <!-- Validation and decryption keys must exactly match and cannot
         be set to "AutoGenerate". The validation and decryption
         algorithms must also be the same. -->
    <machineKey
      validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" 
      decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" 
      validation="SHA1" />
  </system.web>
</configuration>

P.S。

虽然不是真正需要的,但可能是未来的整合是非常有用合并这两个应用程序的StriplingWarrior的意见。你以后可能会结束反正这样做。

StriplingWarrior's advice of merging both applications although not really required but may be very useful for future integrations. You may later end up doing it anyway.

这篇关于我如何共享.NET(C#)基于经验证的Web表单和MVC2应用之间的会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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