Skip to content

Instantly share code, notes, and snippets.

@fredrikhr
Last active August 19, 2021 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrikhr/407e30bc766f8046d7035bb3152c7203 to your computer and use it in GitHub Desktop.
Save fredrikhr/407e30bc766f8046d7035bb3152c7203 to your computer and use it in GitHub Desktop.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FredrikHr.GistIssues.AspnetCoreIStartup", "FredrikHr.GistIssues.AspnetCoreIStartup.csproj", "{D0AD07FA-35AA-4691-9D2A-E9B09132BEDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D0AD07FA-35AA-4691-9D2A-E9B09132BEDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0AD07FA-35AA-4691-9D2A-E9B09132BEDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0AD07FA-35AA-4691-9D2A-E9B09132BEDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0AD07FA-35AA-4691-9D2A-E9B09132BEDF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace FredrikHr.GistIssues.AspnetCoreIStartup
{
public static class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
// Alternatively
// webBuilder.UseStartup(ctx => new Startup(ctx));
});
}
}
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace FredrikHr.GistIssues.AspnetCoreIStartup
{
public class Startup : StartupBase
{
private readonly WebHostBuilderContext context;
public Startup(WebHostBuilderContext context)
{
this.context = context;
}
public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
}
public override void Configure(IApplicationBuilder app)
{
var env = context.HostingEnvironment;
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment