问题描述
我读过很多关于这个职位,但仍不能得到这个工作。我使用Visual Studio 2013年的
我创建了一个新的MVC项目5,并认为它会很酷使用新的Facebook登录的整合。它工作正常,我在IIS快递的PC上。
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.
但是,当我把它上传到我不断收到非常讨厌没有owin.Environment项目生产服务器中被发现背景的消息。
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.
这就是我所做的。
- 我从来没有改变了我的项目或程序集的名称。
- 程序集名称是Wodivate
- 的命名空间是Wodivate
-
我有一个包含以下默认Startup.cs类:
- 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);
}
}
}
在App_Start有它包含一个Startup.Auth.cs文件:
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" />
我也做了一定要遵循的No owin.Environment项目是在上下文中 - 只有在服务器上并安装Microsoft.Owin.Host.SystemWeb
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
任何人都停留在这一点?我一直在击中墙壁3天。
Anyone else stuck on this? I've been hitting a wall for 3 days.
推荐答案
你有没有尝试做这样的事情?
Did you try to do something like this?
<system.webServer>
<modules runAllManagedModulesForAllRequests="false" />
<handlers>
<remove name="StaticFile" />
<add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" />
</handlers>
</system.webServer>
这篇关于Microsoft.Owin.Host.SystemWeb仍然没有得到owin.Environment项目的背景下被发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!