233

I'm getting this error as my project is not able to find the reference for OWIN startup class. I've even installed all the OWIN reference packages through Nuget still getting the same issue. I'm using Visual Studio 2012 and MVC4.

The following errors occurred while attempting to load the app.

  • No assembly found containing an OwinStartupAttribute.
  • No assembly found containing a Startup or [AssemblyName].Startup class. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
Krunal Patil
  • 3,658
  • 5
  • 20
  • 28
  • 7
    Do you have a `Startup.cs` in the project? – christiandev Nov 19 '13 at 09:50
  • 4
    Does your assembly contain an `OwinStartupAttribute`? Does your assembly a `Startup` or `[AssemblyName].Startup` class? Have you disabled OWIN startup discovery, by adding the appSetting `owin:AutomaticAppStartup` with a value of "false" in your web.config? Have you done one of these things and are wondering why it's not working? What is your question? – ta.speot.is Nov 19 '13 at 09:59
  • 1
    Thats the thing. Its not showing the OWIN Startup class when I try to add new Item in my project. I searched on google it says add OWIN References through nugets and I did the same. Still not getting the Class to add. – Krunal Patil Nov 19 '13 at 10:02

19 Answers19

217

Create One Class With Name Startup this will help you..

public class Startup
{
   public void Configuration(IAppBuilder app)
   {
      app.MapSignalR();
   }
}
cracker
  • 4,808
  • 3
  • 18
  • 37
  • 118
    In addition to this, if your startup class is somehow not in your default name space, add a web config line to the `` area like: `` – Andrew Gray Apr 15 '14 at 18:25
  • 7
    Nowaday, there are 3 ways to configurate owin: http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection – Jaider Nov 07 '14 at 00:41
  • @Jaider, This is for the Visual Studio 2013 and the Question is for Visual Studio 2012 :) ;) – cracker Nov 13 '14 at 08:36
  • 22
    In addition to @andrew-gray's comment, putting `[assembly:OwinStartupAttribute(typeof(Identity_Test.Startup))]` into `AssemblyInfo.cs` would work too. – Achilles Jan 26 '15 at 17:50
  • 14
    you also need Microsoft.Owin.Host.SystemWeb package otherwise Startup is not called – rjlopes Sep 30 '15 at 10:49
  • 7
    We could also add this line just before the namespace of Startup class: `[assembly: OwinStartup(typeof([YourStartupNamespaceName].Startup))]` – Minh Nguyen Oct 19 '15 at 15:07
  • Turns out that if you have dashes (hyphens) in your assembly name, then your default namespace will not be the same as your assembly name. – BrainSlugs83 Oct 20 '15 at 23:56
  • 1
    Also, if it's help to anyone, once you get your OwinStartup class configured, be sure to call `WebApp.Start(url)` and NOT `WebApp.Start(url)`. – JohnnyFun Sep 16 '16 at 01:45
195

In our project, we didn't need the OWIN functionality, so we removed all the owin references from the initial ASP.NET MVC template project. The problem occured after removing the OWIN startup class.

The problem was the extra owin dll's in my bin folder. When I deleted them, the problem was resolved. You should delete them by deleting the bin folder. Clean Solution does not delete these dlls.

Somehow, IIS still executes the OWIN dll's when they are in the bin folder.

Hüseyin Yağlı
  • 8,508
  • 4
  • 38
  • 47
  • 6
    I had this problem too and also had to make sure the References didn't reference any OWIN DLL's. – hacker Jul 17 '14 at 14:57
  • 2
    Same issue and same solution. However in my case I had one branch of code with Signalr and one without. When switching branches the Signalr dlls remained even after a Clean. I needed to manually delete them. – Kywillis Oct 21 '14 at 15:36
  • 3
    Just a note to say this literally means the bin folder not just using "Clean Solution" from Visual Studio which in my case was deleting most DLLs but not all. – Alan Macdonald Jun 23 '15 at 10:59
  • It's ridiculous that OWIN cannot be cleanly removed without manual steps like this, but this is exactly what the problem was. Someone please file a bug. – Triynko Jul 05 '16 at 14:39
  • 1
    Something that worked for me, is after deleting OWIN references and it still not working properly was adding `` as an appSetting. Just some advice to people trying this and it still not succeeding. – LatentDenis Jul 29 '16 at 17:27
  • I am not sure why clean and rebuild doesnt work in this case. I had to manually delete those dlls and it worked. Thanks! – prashant Mar 07 '17 at 00:28
  • Also solved my problem, thanks you! I think the dlls are left in the previous build... – code4j Mar 23 '17 at 01:49
  • 1
    For people who this didn't work for, make sure that even after you have deleted the bin folders that you go into the project references and remove references to the Owin dll's. In my case I deleted the bin folders but forgot I still had the (unused) references sitting in the .csproj file. – akousmata Apr 03 '17 at 16:36
  • @akousmata If you don't delete the references, the owin dll's will be copied into your bin folder each time you build the project. Removing the references should be the first thing to do. – Hüseyin Yağlı Apr 05 '17 at 14:03
  • @HüseyinYağlı yes I realize this. It was just something that I overlooked the first time I tried this solution. Posted the comment just as a friendly reminder. – akousmata Apr 05 '17 at 15:03
108

On Visual Studio 2013 RC2, there is a template for this. Just add it to App_Start folder.

enter image description here

The template produces such a class:

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(WebApiOsp.App_Start.Startup))]

namespace WebApiOsp.App_Start
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        }
    }
}
Timuçin
  • 4,597
  • 3
  • 23
  • 33
  • 3
    VS2015 needed this as well – Tom Stickel Jul 21 '15 at 00:26
  • 2
    This did it for me - I created the Startup.cs file and populated it correctly but missed that it needed to be in the App_Start folder. Ran fine on my dev machine, but once published was erroring out. Thanks! – Jon Peterson Aug 14 '15 at 20:39
  • Remember to add app.MapSignalR(); in Configuration(IAppBuilder app), else 404 is returned when calling [YourSite]/signalr – Kasper Halvas Jensen Aug 29 '16 at 08:04
  • Thanks for the screenshot. That really helps. – sabhari karthik Jul 17 '20 at 04:12
  • For the benefit of posterity, I recently got this error while trying to implement the Dancing Goat account related features into a new Kentico MVC project created under Kentico 12SP. After getting the correct Owin packages installed the error in this post came up. After following the recommendation of this post it was fixed. TYVM :) – TonyT Aug 19 '20 at 00:59
45

If you don't want to use the OWIN startup, this is what you should add to your web.config file:

Under AppSettings add the following line:

    <add key="owin:AutomaticAppStartup" value="false" />

This is how it should look like in your web.config:

  <appSettings>
    <add key="owin:AutomaticAppStartup" value="false" />
  </appSettings>
Yonatan Ayalon
  • 1,769
  • 16
  • 19
  • 1
    This is actually one of the complete answers. If you're not very into web.config settings, it's hard to figure that you should add a *key* and a *value* in the xml file – makoshichi Jan 26 '18 at 20:29
25

Have a look for the Startup.cs file, you might be missing one of these. This file is the entry point for OWIN, so it sounds like this is missing. Take a look at OWIN Startup class here to understand whats going on.

As your error specifies, you can disable this in the web.config by doing the following...

To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config

christiandev
  • 16,394
  • 8
  • 42
  • 74
18

First you have to create your startup file and after you must specify the locale of this file in web.config, inside appSettings tag with this line:

<add key="owin:AppStartup" value="[NameSpace].Startup"/>

It solved my problem.

Slaters
  • 483
  • 5
  • 8
11

I had this problem, understand this isn't what was wrong in the OP's case, but in my case I did have a Startup class, it just wasn't finding it by default.

My problem was the I had spaces in my Assembly Name, and hence the default namespace was different from assembly name, hence the namespace for the startup class was different than the assembly name.

As the error suggests, by convention it looks for [Assembly Name].Startup for the class... so be sure the namespace for your Startup class is the same as the Assembly name. Fixed the problem for me.

TCC
  • 2,476
  • 1
  • 22
  • 34
  • 1
    I had a similar problem. My project name had a '-' hyphen in it, which was converted to underscore by VS, so the namespace and the startup class were essentially different. – LDJ Aug 29 '14 at 11:58
7

I tried most of the recommended fixes here, and still couldn't avoid the error message. I finally performed a combination of a few recommended solutions:

  1. Added this entry to the top of the AppSettings section of my web.config:

    <add key="owin:AutomaticAppStartup" value="false"/>

  2. Expanded the References node of my project and deleted everything that contained the string OWIN. (I felt safe doing so since my organization is not (and won't be) an active OWIN provider in the future)

I then clicked Run and my homepage loaded right up.

Community
  • 1
  • 1
Jason Marsell
  • 1,512
  • 1
  • 16
  • 10
4

In my case, I had renamed the project and changed it's folder structure. I found that updating the RootNameSpace and AssemblyName in the .csproj file where the error was being thrown resolved the error. If you have modified paths of your project I'd recommend checking this as well.

<RootNamespace>Company.Product.WebAPI</RootNamespace>
<AssemblyName>Company.Product.WebAPI</AssemblyName>
Unlearnd
  • 51
  • 2
  • Holy cow kudos to you bro, was stuck on it like forever and found no solution until I read this, the AssemblyName wasn't updated after I changed it manually. Now it works! Thank you so much! – Mason Nov 02 '17 at 09:35
3

My case? I had startup file, but it is excluded in the project. I just included it and the error left.

Gellie Ann
  • 429
  • 1
  • 5
  • 10
3

This could be faced in Visual Studio 2015 as well when you use the Azure AD with a MVC project. Here it create the startup file as Startup.Auth.cs in App_Start folder but it will be missing the

[assembly: OwinStartup(typeof(MyWebApp.Startup))]

So add it and you should be good to go. This goes before the namespace start.

Diceyus
  • 709
  • 8
  • 13
3

Are you really trying to add OWIN to your project or is this something unexpected?

  1. In case you want to add OWIN, adding a Startup class is the way to go.

  2. In case you don't need any reference to Owin:

    delete Owin.dll from your /bin folder.

    Owin.dll is the one trying to identify the Startup class.

carraua
  • 1,039
  • 11
  • 29
2

It is also possible to get this exception (even when you have a correctly configured startup class) if running through IIS Express and your virtual directory is not configured correctly.

When I encountered this issue, the resolution was simply to press the 'Create Virtual Directory' button in the 'Web' tab of project properties (Using Visual Studio 2013)

mcarter
  • 78
  • 6
1

While I can't fully explain why this solved the issue for me, I ran into a problem like this after I changed my API project to build to separate \debug and \release folders. Once I reverted that change back to build to a single \bin folder things started working.

I wrote up my experience here: Can't get the OWIN Startup class to run in IIS Express after renaming ASP.NET project file

Community
  • 1
  • 1
Sam Storie
  • 3,934
  • 3
  • 37
  • 70
1

I ran into this problem after experimenting with SignalR and then removing it from the project. To resolve I had to delete the contents of the bin folder for the site on the remote server and then publish again.

Owen Pauling
  • 9,864
  • 18
  • 50
  • 58
1

Just check that your packages.config file is checked in (when excluded, there will be a red no-entry symbol shown in the explorer). For some bizarre reason mine was excluded and caused this issue.

Ian
  • 2,230
  • 1
  • 18
  • 23
0

I kept getting the same error when I started my project using the Browser Link Dashboard in VS2013. But, when I ran my project in debug mode, it would work. I could not figure out why and how to get the Browser Link Dashboard working. I checked the startup file, it was fine, added the appSetting line as described in some of the answers "", but nothing worked.

Apparently, what I was doing wrong was clicking on the WRONG link in the Browser Dashboard. All the Solutions projects links show in the Browser Dashboard, but only the startup projects link works. You need to click on the link of the startup project.

Example: I have 2 projects, both show in the Browser Dashboard, but only the one marked as the start up project will work (shows as bold in the Solution Explorer.) I thought this may help someone do the obvious, it cost me 2 days to stumble on to the obvious.

alikuli
  • 528
  • 5
  • 18
0

I had this problem when I got the latest on TFS while other projects were open in multiple instances of VS. I already have all the fixes above. Reopening VS fixed the problem.

PersyJack
  • 1,173
  • 1
  • 13
  • 30
0

In my case I logged into ftp server. Took backup of current files on ftp server. Delete all files manually from ftp server. Clean solution, redeployed the code. It worked.

Kurkula
  • 6,673
  • 23
  • 99
  • 170