Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OWIN Startup Class Called multiple times

Tags:

c#

asp.net

owin

Am having a design crisis.

I have few things which have to remain static during my application lifetime.

A public void Configuration(IAppBuilder app) method in Startup.cs class is being called ore than once, Also they appear to be multiple instances of "static" variables.

I have this on my startup class

[assembly: OwinStartup(typeof(Startup))]

Am also using these parkages

  <package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.SignalR.Core" version="2.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Cors" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="WebGrease" version="1.5.2" targetFramework="net45" />

How can i insure that the configuration in startup.cs is executed only once?

like image 616
konzo Avatar asked Mar 09 '23 17:03

konzo


1 Answers

This happened to me with startup running exactly twice. The problem was this

<add name="Owin" verb="" path="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb"/>

I removed this line from config and that fixed it

enter image description here

like image 148
Samuel Avatar answered Mar 19 '23 05:03

Samuel