No assembly found containing an OwinStartupAttribute. error in asp.net mvc project


Hi, I have just created a project using Visual Studio 2015 & selected MVC template, but When I tried to build the project and executed it in the browser, I got the error as below

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.

Here is the Image of the error

owin-start-up-class-in-missing-asp-net-mvc-min.png

How can I resolve this error?What did I miss?

Thanks


Asked by:- Vinnu
0
: 8808 At:- 3/12/2018 12:45:37 PM
C# asp.net mvc owin







2 Answers
profileImage Answered by:- neena

1. Check if there is Startup.cs file in the root folder of your project, if not please create startup.cs in the root of propject like below example

public class Startup
{
    //For more information on how to configure your application,
    //visit http://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
                services.AddMvc();
    }

    public void Configure(IApplicationBuilder app)
    {
             app.UseMvc();
    }
}

2. OR add the key owin:AutomaticAppStartup set to false in your appSettings

<appSettings>

   <addkey="owin:AutomaticAppStartup" value=“false“ />

</appSettings>

One of the above solutions should solve your issue

2
At:- 3/13/2018 2:15:49 PM Updated at:- 3/13/2018 2:16:30 PM
First solution worked for, I checked my solution explorer, I was missing Startup.cs file, so created it as explained by you and it worked, so I didn't try 2nd solution, thanks 0
By : Vinnu - at :- 3/16/2018 12:14:39 PM


profileImage Answered by:- bhanu

If you got this error, while removing OWIN from your project, you can do this

  • Delete OWIN references and Nuget packages from project
  • OWIN file are still in build, so delete them from bin/directory manually
  • Now clean and rebuild project

For those who want OWIN and getting this error

  • If you have a partial class "Startup" in your Startup.Auth file, create another partial Startup class in the root of your project.
  • Define an assembly owinstartup attribute pointing to that class
  • Create a "Configuration" method
    using Microsoft.Owin;
    using Owin;
    
    [assembly: OwinStartupAttribute(typeof(ProjectNameSpace.Startup))]
    namespace ProjectNameSpace
    {
        public partial class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                ConfigureAuth(app);
            }
        }
    }?
  • If your app setting, add OWIN key
    <appSettings>
    
       <addkey="owin:AutomaticAppStartup" value=“false“ />
    
    </appSettings>?
  • Now, rebuild project.

That's it.

0
At:- 8/29/2021 3:01:25 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use