// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; namespace Demo { public class Startup { private const string PATH = "/testapi"; public void ConfigureServices(IServiceCollection services) { ////services.AddCors(options => options.AddPolicy("AlmostAnythingGoes", builder => builder.AllowAnyOrigin().WithHeaders("Content-Type").WithMethods("GET", "POST", "PUT", "DELETE", "OPTIONS"))); services.AddMvc().AddXmlDataContractSerializerFormatters(); // XML support is not added by default - and AddXmlSerializerFormatters will add a formatter that ignores DataContract attributes } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UsePathBase(PATH); ////app.UseCors(); app.UseMvc(); } } public class Program { private const string URL = "http://localhost:8084"; public static void Main(string[] args) { WebHost.CreateDefaultBuilder(args).UseUrls(URL).UseStartup().Build().Run(); } } }