Authentication sharing between diverse .Net apps

>> Saturday, July 24, 2010

I work at a company that has a .Net WebForms app on .Net 3.5. Pretty standard stuff, but from that we would like to link a .Net MVC app, and already be authenticated (We have WebForm authentication in the original Webforms app).

I thought this would be a pretty frequent scenario, but Google tells me otherwise, so I thought I would post on how to "git-r-done".

There are a few ways to do this, I chose a pretty simple, yet effective method. First off, copy your Authentication method section from your parent app into the child web.config. Exactly as is, no changes.

You will also need to share a machine key between the two applications, this is the insurance that the apps can share authentication. Simply add a MachineKey to your web config:

That's all there is to it, now you can simply link the child app from the parent app and authentication will be passed and not required again, pretty cool!

There is one more thing that is key. Web.config settings are inherited by default. The way around that is easy as well. Simply wrap your System.web section in the parent web.config with the location tag and the "inheritInChildApplications" attribute.


So there it is! I have a complete separate MVC app sharing authentication behind the scenes with a legacy webforms app, took a while to figure out these little trick so thought I would share.


  © Blogger templates Sunset by 2008

Back to TOP