I feel I've got the same problem as described in this thread. I am working on an ASP.NET MVC web application that runs fine locally. When deployed to our Windows Server 2008 with IIS7, however, I get the following error when trying to log in:
No owin.Environment item was found in the context.
This is the line that triggers this error:
return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
I have tried all I could find:
<add key="owin:AppStartup" value="My_App.Startup,My-App"/>
toe the web.config. My Application has a hyphen in its name, but
that should not be a problem, right?<add key="owin:AutomaticAppStartup" value="true"/>
to the
web.config.<modules runAllManagedModulesForAllRequests="true">
to the
web.config.Microsoft.Owin.Host.SystemWeb
is installed and in the
bin-folder.It's working just fine locally. What am I missing?
This is not a duplicate of this thread. I have tried the solution from there (see my #1) to no success. Also, I have not changed the namespace.
Edit One solution is to register the OwinHttpHandler explicitly in the web.config but this had some strange side effects (my CSS and JavaScript are not loaded anymore, Status 404?):
<handlers>
<add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" />
</handlers>
Naming Convention: Katana looks for a class named Startup in namespace matching the assembly name or the global namespace.
OwinStartup Attribute: This is the approach most developers will take to specify the startup class. The following attribute will set the startup class to the TestStartup class in the StartupDemo namespace.
[assembly: OwinStartup(typeof(StartupDemo.TestStartup))]
<appSettings>
<add key="owin:appStartup" value="StartupDemo.ProductionStartup" />
</appSettings>
The following key, which explicitly specifies the startup class and assembly can also be used:
<add key="owin:appStartup" value="StartupDemo.ProductionStartup, StartupDemo" />
<appSettings>
<add key="owin:appStartup" value="ProductionConfiguration" />
</appSettings>
The above markup must be used with the following OwinStartup attribute which specifies a friendly name and causes the ProductionStartup2 class to run.
[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");
});
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With