Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should i set mvcoptions.enableendpointrouting in .net core

I have added what I have tired , I'm trying to set mvcoptions.enableendpointrouting in ConfigureServices method

  public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                DeveloperExceptionPageOptions developerExceptionPageOptions = new DeveloperExceptionPageOptions()
                {
                    SourceCodeLineCount = 1
                };
                app.UseDeveloperExceptionPage(developerExceptionPageOptions);
            }

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
like image 375
trust Avatar asked Dec 13 '19 07:12

trust


People also ask

What is EnableEndpointRouting?

Endpoint routing is used to match HTTP requests to MVC actions, and to generate URLs with IUrlHelper. public: property bool EnableEndpointRouting { bool get(); void set(bool value); }; C# Copy.

What is use of UseRouting and UseEndpoints in startup configure method?

UseRouting adds route matching to the middleware pipeline. This middleware looks at the set of endpoints defined in the app, and selects the best match based on the request. UseEndpoints adds endpoint execution to the middleware pipeline. It runs the delegate associated with the selected endpoint.

What are the differences between app UseRouting () and APP UseEndpoints ()?

UseRouting adds metadata that can be used by subsequent middleware. UseEndpoints executes the Controller and corresponding handler.

What is UseMvc?

UseMvc(IApplicationBuilder) Adds MVC to the IApplicationBuilder request execution pipeline. UseMvc(IApplicationBuilder, Action<IRouteBuilder>) Adds MVC to the IApplicationBuilder request execution pipeline.


1 Answers

Welcome to the site. You can enable/disable endpoint routing the following way:

public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(x => x.EnableEndpointRouting = false);
           ...
        }
like image 63
SpiritBob Avatar answered Sep 20 '22 15:09

SpiritBob