views:

45

answers:

2

Our company is currently running a asp.net Webforms 3.5 website as the default website on a Server.

I would like to add a new asp.net MVC application (using .net 4.0), but be able to use Single Sign-On authentication from the forms app to the MVC app. How can I do this?

I tried added the MVC app to the default website, but the MVC app fails since it is trying to read the web.config of the WebForms application.

I would imagine this has been done by someone out there, what is a good way to do this? Any help would be appreciated.

+1  A: 

You can't.

Your basically trying to use a 4.0 and 3.5 app pool at the same time. Just won't work.

I'd downgrade your MVC site to 3.5.

jfar
Thanks Jfar, I took your advice and downgraded to 3.5, there is nothing in 4.0 I am really needing right now, plus I can always upgrade later.
Mark Kadlec
+3  A: 

CLR version is set in IIS per application pool => if you want to have two applications running two different CLR versions (2.0 and 4.0) you need to create two application pools. Once you create a second application pool you add a virtual directory and assign it to this application pool.

As for the SSO if you are using FormsAuthentication all that's necessary is to use the same <authentication mode="Forms"> section in both applications web.config. In order for an authentication cookie created by the first application to be decrypted by the second same machine keys need to be used => check out this article.

Darin Dimitrov
Thanks Darin, I've set it up exactly as you described, but the problem seems to be with the WebForms being the default web site. When I try to hit the MVC app, it complains about the web.config of the Webforms app. Not sure why it is trying to validate the web.config of the WebForms app.
Mark Kadlec
Try setting a physical path for the ASP.NET MVC application that is outside of the root folder for the main web site. Example: root web site - `d:\inetpub\wwwroot`, asp.net mvc root - `d:\myapp`
Darin Dimitrov
They are separated already c:\Projects\CPortal\CPortal (for the WebForms is the root for the default WebSite) and c:\SmartForms\SmartForms for the MVC app.
Mark Kadlec
What if you create a new web site for the ASP.NET MVC application?
Darin Dimitrov
I tried that too Darin, but then I won't be able to use the Domain cookie Single Sign-on method that Michal talks about in the article you recommended. Or can I still do that somehow?
Mark Kadlec
You can as long as you keep the same domain (sub domain can be different). You just need to set the domain name in web.config: `<forms name=".EXAMPLE-AUTH" loginUrl="/Login.aspx" protection="All" timeout="30" domain="example.com" />`. This will work for both `foo.example.com` and `bar.example.com` and also `example.com`.
Darin Dimitrov
Works perfect, thanks Darin!
Mark Kadlec