I've read lots of posts on this but still can't get this to work. I'm using Visual Studio 2013. I created a new MVC 5 Project and thought it would be cool to use the new facebook login integration. It works fine on my PC in IIS Express.
But when I upload it to the Production server I keep getting the very annoying "No owin.Environment item was found in the context" message.
Here's what I've done.
- I never changed the name of my project or assembly.
- The assembly name is Wodivate
- The namespace is Wodivate
I have the default Startup.cs class which contains the following:
using Microsoft.AspNet.Identity; using Microsoft.Owin; using Microsoft.Owin.Security.Cookies; using Owin; using System.Web.Http; [assembly: OwinStartupAttribute(typeof(Wodivate.Startup))] namespace Wodivate { public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); } } }
In the App_Start there is a Startup.Auth.cs file which contains:
using Microsoft.AspNet.Identity; using Microsoft.Owin; using Microsoft.Owin.Security.Cookies; using Owin; namespace Wodivate { public partial class Startup { // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); // Use a cookie to temporarily store information about a user logging in with a third party login provider app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions() { AppId = "xxxxxxxxxxxxxxxxxxx", AppSecret = "xxxxxxxxxxxxxxxxxxxxxxxxx" }; facebookOptions.Scope.Add("email"); //We want to get user's email information by adding it in scope. app.UseFacebookAuthentication(facebookOptions); //app.UseGoogleAuthentication(); } } }
My Web.config file includes:
<add key="owin:AppStartup" value="Wodivate.Startup, Wodivate" /> <add key="owin:AutomaticAppStartup " value="false" />
I also made sure to follow the post on No owin.Environment item was found in the context - only on server and installed Microsoft.Owin.Host.SystemWeb
Anyone else stuck on this? I've been hitting a wall for 3 days.