1

I'm unable to trigger 'Configuration' method in my web api core, but i'm able to trigger 'Startup' method. What could be the problem? Please see my code below:

public class Startup
    {
        public IConfiguration Config { get; }

        //able to trigger this method
        public Startup(IConfiguration configuration)
        {            
            Config = configuration;
        }

        //cant trigger this method
        public void Configuration(IAppBuilder app)
        {
            ConfigureOAuth(app);
        }

        //able to trigger this method
        public void ConfigureServices(IServiceCollection services)
        {
        }

        //able to trigger this method
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

        }
}
1
  • Can you confirm platform version? I am seeing code for asp.net-core and Owin start up in asp.net-web-api-2.* Commented Dec 4, 2018 at 16:28

1 Answer 1

2

Configuration is not one of the by convention named members associated with Startup.

Also IAppBuilder is from the previous version of asp.net-web-api and was normally associated with Owin's Startup.

The Startup class

ASP.NET Core apps use a Startup class, which is named Startup by convention.

The Startup class:

  • Can optionally include a ConfigureServices method to configure the app's services.
  • Must include a Configure method to create the app's request processing pipeline.

ConfigureServices and Configure are called by the runtime when the app starts:

public class Startup
{
    // Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        ...
    }

    // Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app)
    {
        ...
    }
}

Reference App startup in ASP.NET Core

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.