1

In regular MVC app, the Application_Start method (and others) is not virtual. Therefore, this method must be called through reflection, and there are som naming convention. But why did they choose it like so? Instead, I would rather look at the base class' virtual methods and choose one to override. Now I have to go to docs. Why don't declare even handling methods in the base class.

P.S. In the new ASP.NET Core the Startup class even has no base class.

1
  • 1
    Why did they do it like that? Likely because ASP.NET inherited this approach from classic ASP. But any answers outside of the original development team (including this comment) will be speculative at best. Commented Nov 15, 2016 at 8:14

1 Answer 1

2

In former applications, the "entry" is not called from managed .NET code, naming convention is the most direct way, imagine static void Main.

For ASP.NET core applications, the entry is Main method, where you can specify a startup class using .UseStartup method of IWebHostBuilder extension. There is no constraint of IStartup is because its signature can be changed, for example:

public void Configure(IApplicationBuilder app)

public void Configure(IApplicationBuilder app, IHostingEnvironment env)

public void Configure(IApplicationBuilder app, IEmailService emailService)

The arguments are resolved by IServiceProvider, registered in ConfigureServices method.

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.