我觉得我遇到了与此主题中描述的问题相同的问题.我正在开发一个在本地运行良好的ASP.NET MVC Web应用程序.但是,当使用IIS7部署到我们的Windows Server 2008时,尝试登录时出现以下错误:
在上下文中找不到owin.Environment项.
这是触发此错误的行:
return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
Run Code Online (Sandbox Code Playgroud)
我尝试了所有我能找到的东西:
<add key="owin:AppStartup" value="My_App.Startup,My-App"/>web.config脚趾.我的应用程序在其名称中有一个连字符,但这应该不是问题,对吧?<add key="owin:AutomaticAppStartup" value="true"/>到web.config.<modules runAllManagedModulesForAllRequests="true">到web.config.Microsoft.Owin.Host.SystemWeb已安装并在bin文件夹中.它在当地工作得很好.我错过了什么?
这不是此主题的重复.我从那里尝试过解决方案(参见我的#1)但没有成功.另外,我还没有更改名称空间.
编辑 一个解决方案是在web.config中显式注册OwinHttpHandler但这有一些奇怪的副作用(我的CSS和JavaScript不再加载,状态404?):
<handlers>
<add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" />
</handlers>
Run Code Online (Sandbox Code Playgroud)
小智 1
命名约定: Katana 在与程序集名称或全局命名空间匹配的命名空间中查找名为 Startup 的类。
OwinStartup 属性: 这是大多数开发人员指定启动类的方法。以下属性将启动类设置为 StartupDemo 命名空间中的 TestStartup 类。
[assembly: OwinStartup(typeof(StartupDemo.TestStartup))]
<appSettings>
<add key="owin:appStartup" value="StartupDemo.ProductionStartup" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
还可以使用以下显式指定启动类和程序集的键:
<add key="owin:appStartup" value="StartupDemo.ProductionStartup, StartupDemo" />
<appSettings>
<add key="owin:appStartup" value="ProductionConfiguration" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
上述标记必须与以下 OwinStartup 属性一起使用,该属性指定友好名称并导致 ProductionStartup2 类运行。
[assembly: OwinStartup("ProductionConfiguration", typeof(StartupDemo.ProductionStartup2))]
namespace StartupDemo
{
public class ProductionStartup
{
public void Configuration(IAppBuilder app)
{
app.Run(context =>
{
string t = DateTime.Now.Millisecond.ToString();
return context.Response.WriteAsync(t + " Production OWIN App");
});
}
}
public class ProductionStartup2
{
public void Configuration(IAppBuilder app)
{
app.Run(context =>
{
string t = DateTime.Now.Millisecond.ToString();
return context.Response.WriteAsync(t + " 2nd Production OWIN App");
});
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1526 次 |
| 最近记录: |