Skip to content

Instantly share code, notes, and snippets.

@michael-wolfenden
Last active October 25, 2018 10:43
Show Gist options
  • Save michael-wolfenden/eb8cbefba8511c2be5fea7c1b71ee117 to your computer and use it in GitHub Desktop.
Save michael-wolfenden/eb8cbefba8511c2be5fea7c1b71ee117 to your computer and use it in GitHub Desktop.
aspnetcore microservice - linqpad
<Query Kind="Program">
<NuGetReference>Microsoft.AspNetCore</NuGetReference>
<NuGetReference>Microsoft.AspNetCore.Mvc.Core</NuGetReference>
<NuGetReference>Microsoft.AspNetCore.Mvc.Formatters.Json</NuGetReference>
<NuGetReference>System.ValueTuple</NuGetReference>
<Namespace>Microsoft.AspNetCore</Namespace>
<Namespace>Microsoft.AspNetCore.Builder</Namespace>
<Namespace>Microsoft.AspNetCore.Hosting</Namespace>
<Namespace>Microsoft.AspNetCore.Mvc</Namespace>
<Namespace>Microsoft.Extensions.DependencyInjection</Namespace>
</Query>
#define NONEST
public class Microservice : ControllerBase
{
[HttpGet("/")]
public IActionResult Hello() =>
new JsonResult(new { Message = "Hello World" });
public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment env) =>
applicationBuilder
.UseMvc();
public void ConfigureServices(IServiceCollection services) =>
services
.AddMvcCore()
.AddJsonFormatters();
private static void Main(string[] args)
{
using (var host = WebHost
.CreateDefaultBuilder(args)
.UseStartup<Microservice>()
.Build())
{
host.Start();
Console.ReadLine();
}
}
}
@oguzhaneren
Copy link

I'm getting an error when restoring nuget packages

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment