Unique authentication for multiple projects using Entity Framework

2

Currently in my solution I have several ASP.NET web projects, each with the default default authentication code of the MVC entity framework (there are small customizations in entities only). The projects share the same entities and the same database.

The problem is when I want to access two projects at the same time. For example, when you access the "Financial" project, the "Sales" project that was already logged on, it shifts.

How do I keep both projects logged in at the same time with the same user?

    
asked by anonymous 19.04.2017 / 18:19

1 answer

2

First step is to have a cookie unique for all projects, to do so, edit your web.config and assign the same name to the Authentication Cookie.

<authentication mode="Forms">
  <forms name=".MY_AUTH_COOKIE_NAME" protection="All" cookieless="AutoDetect" enableCrossAppRedirects="true" path="/" />
</authentication>

But taking into account that the system is already logging out of other systems by logging into a system, I believe all applications are sharing the same cookie, so you can skip this step.

The second point is to ensure that all applications have the same machinekey , again you will have to set this in web.config :

<machineKey
  validationKey="336C0D608AF11D8B6613F6D235C980885F74B284254A034FA33E59E39FAB7987BD97F3DE9DEA14A1B625966642CBAC92A46DDB5EBF5CDDB44C7DB0F1CB4D5887"
  decryptionKey="A71C792B7E90217ECBCFCCE25E24466B2E52C3ED686513C2FA2418639624626F"
  validation="SHA1" decryption="AES"
/>

You can refer to the following article to learn how to generate the machineKey .: Easiest way to generate MachineKey

If you are using ASP.NET Identity with Entity Framework and have set tag "forms-authentication" erronia, then read the following article: #

    
19.04.2017 / 19:09