Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Configure(IApplicationBuilder app)
- {
- app.UseMvc(); // you don't need this
- }
- public void Configure(IApplicationBuilder app)
- {
- app.Map("/api", HandleMapApi);
- // notice how we don't have app.UseMvc()?
- }
- private static void HandleMapApi(IApplicationBuilder app)
- {
- app.Run(async context =>
- {
- // implement your own response
- await context.Response.WriteAsync("Hello WebAPI!");
- });
- }
- var builder = services.AddMvcCore();
- builder.AddViews();
- builder.AddRazorViewEngine();
- builder.AddRazorPages();
- public void ConfigureServices(IServiceCollection services)
- {
- // Build a customized MVC implementation, without using the default AddMvc(),
- // instead use AddMvcCore(). The repository link is below:
- // https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc/MvcServiceCollectionExtensions.cs
- services
- .AddMvcCore(options =>
- {
- options.RequireHttpsPermanent = true; // this does not affect api requests
- options.RespectBrowserAcceptHeader = true; // false by default
- //options.OutputFormatters.RemoveType<HttpNoContentOutputFormatter>();
- // these two are here to show you where to include custom formatters
- options.OutputFormatters.Add(new CustomOutputFormatter());
- options.InputFormatters.Add(new CustomInputFormatter());
- })
- //.AddApiExplorer()
- //.AddAuthorization()
- .AddFormatterMappings()
- //.AddCacheTagHelper()
- //.AddDataAnnotations()
- //.AddCors()
- .AddJsonFormatters();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement