본문 바로가기

카테고리 없음

.net 닷넷 mvc 세팅

 

 

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.Extensions.DependencyInjection;

namespace WebApplication3
{

    //엔진같은 부분입니다
    public class Startup
    {

        
        //모든곳에서 사용할수 있게끔 만들어주는곳
        public void ConfigureServices(IServiceCollection services)
        {
            //mvc패턴이용하기
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //wwwroote폴더에 있는것들 사용하겠다
            app.UseStaticFiles();
            //app.UseStaticFiles();
            //라우팅하기
            app.UseMvc(routes =>
            {
                //home라는것에 sutdent를 첫화면으로 보여줍니다
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                
            });

            //앱이 열렸을때 실행하라
            /*app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });*/
        }
    }
}