4

I am curious about Startup class in ASP.NET MVC 5, when I remove the assembly attribute from the Startup class, the code inside Startup class is still being executed.

using Microsoft.Owin;
using Owin;
using SignalRChat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

//[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{
   public class Startup
   {
       public void Configuration(IAppBuilder app)
       {
        app.MapSignalR();
    }
   }
}

Anybody can tell me why this happened?

Thanks

1
  • try to clean the build and rebuild the solution Commented Mar 7, 2018 at 6:38

1 Answer 1

8

OWIN Startup Class Detection | The ASP.NET Site:

You connect the startup class with the hosting runtime using one of the these approaches:

  • 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 appSetting element in the Configuration file

Emphasis mine. Your class is used because of its name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.