Thursday, March 14, 2019

asp.net core simple web

create a dir
dotnet new web
creates Startup.cs and other files
dotnet run
browse localhost:5000


static files:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2
in Startup.cs

  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

            app.UseStaticFiles(); }

then create test.htm in wwwroot with any text in it
browse localhost:5000/test.htm

or:
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

            app.UseStaticFiles();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }

No comments: