Reputation: 2202
I'm trying to get the ASP.NET Identity to work on a parent domain. I was able to successfully configure the authentication cookie to be accessible from my parent domain by setting the CookiePath (.mydomain).
Although I'm not sure it is necessary, I also set a machinekey tag with the same values in the web.config of both projects.
Issue:
Currently, even though the cookie is shared with my parent domain, it still does not seem to be registering that it is authenticated, even with the cookie there. I have an <authorization>
tag to deny anonymous users, and my app is still redirecting to login page (located on subdomain).
Just in case this makes a difference: I am running these 2 projects on localhost from Visual Studio, with domain / subdomain configured on IISExpress. (Parent project is localhost.com and subdomain project, which does the authentication, is secure.localhost.com.)
I tried troubleshooting by checking if the user is authenticated with Request.GetOwinContext()
on localhost.com (parent domain), however my application errors out on that line with the following:
No owin.Environment item was found in the context.
What else do I need to do to get ASP.NET identity working on my parent domain?
Upvotes: 1
Views: 733
Reputation: 562
This is about the exception 'No owin.Environment item was found in the context.' from Request.GetOwinContext(). It usually means that the OWIN startup class detection failed.
Check the following: In both projects, you'll find the file Startup.cs in the root folder of each with the following code:
[assembly: OwinStartupAttribute(typeof(XXX.XXX.Startup))]
namespace Project.Web.Client
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}
Make sure this code is executed on startup. More information here: http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection
Upvotes: 1