Przeczytałem wiele postów na ten temat, ale nadal nie mogę tego uruchomić. Używam Visual Studio 2013. Stworzyłem nowy projekt MVC 5 i pomyślałem, że byłoby fajnie używać nowej integracji z Facebookiem. Działa dobrze na moim komputerze w IIS Express.Microsoft.Owin.Host.SystemWeb i nadal otrzymuję Brak elementu owin.Environment został znaleziony w kontekście
Ale kiedy przesyłam go na serwer produkcyjny, otrzymuję bardzo denerwujący komunikat "Nie znaleziono elementu owin.Environment w kontekście".
Oto, co zrobiłem.
- Nigdy nie zmieniłem nazwy mojego projektu lub zespołu.
- Nazwa zespołu jest Wodivate
- Przestrzeń nazw jest Wodivate
mam domyślną klasę Startup.cs który zawiera następujące elementy:
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); } } }
W App_Start jest Startup.Auth. plik CS, który zawiera:
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(); } } }
Mój plik Web.config obejmuje:
<add key="owin:AppStartup" value="Wodivate.Startup, Wodivate" /> <add key="owin:AutomaticAppStartup " value="false" />
Ja również zadbał, aby podążać za post No owin.Environment item was found in the context - only on server i zainstalowane Microsoft.Owin.Host.SystemWeb
Ktoś jeszcze zatrzymany w tej sprawie? Uderzam w ścianę przez 3 dni.
Duplikat: http://stackoverflow.com/questions/18232549/no-owin-environment-item-was-found-in-the-context –
Widziałem ten post zbyt Morten, ale to nie działało dla mnie .Chcesz sprawdzić, czy ktoś widział te wszystkie posty i czy nadal tkwi lub znalazł coś innego, aby go rozwiązać. To jest tak dziwne .. – user3562747
Upewnij się, że twój Web.config naprawdę trafił w odpowiednie miejsce na serwerze produkcyjnym ... – Dunken