wingman007 icon

Startup.cs

wingman007 | PRO | 12/01/19 05:45:28 PM UTC | 0 ⭐ | 783 👁️ | Never ⏰ | []
C# |

3.09 KB

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
 
namespace myweb
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            // services.AddMvc(); // services.AddMvc();
            // MvcOptions.EnableEndpointRouting = false;
            // services.AddRazorPages();
 
            // for Razor
            //services.AddRazorPages();
 
            // for MVC
            // services.AddControllersWithViews();
 
            // for API
            services.AddControllers();
        }
 
        // 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())
            {
                app.UseDeveloperExceptionPage();
            }
            /* for API comment
            else
            {
                // for Razor
                // app.UseExceptionHandler("/Error");
 
                // for MVC
                app.UseExceptionHandler("/Home/Error");
 
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            */
 
            // for Razor
            // for MVC
            // for API
            app.UseHttpsRedirection();
 
            // for Razor
            // for MVC
            // for API - comment
            // app.UseStaticFiles();
 
            // for All
            app.UseRouting();
 
 
            // for Razor
            // for MVC
            // for API
            app.UseAuthorization();
 
            //for Razor
            // app.UseEndpoints(endpoints =>
            // {
            //     endpoints.MapRazorPages();
            // });
 
            // for MVC
            // app.UseEndpoints(endpoints =>
            // {
            //     endpoints.MapControllerRoute(
            //         name: "default",
            //         pattern: "{controller=Index}/{action=Index}/{id?}");
            // });
 
            // for API
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
 
            // for web
            // app.UseEndpoints(endpoints =>
            // {
            //     endpoints.MapGet("/", async context =>
            //     {
            //         await context.Response.WriteAsync("<h1>Hello World George S</h1>");
            //     });
            // });
 
        }
    }
}

Comments