WebMAP From Scratch
Using VS 2019
namespace DemoApp { using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Mobilize.Web; using Mobilize.WebMap.Common.Core; using Mobilize.WebMap.Common.DCP; using Mobilize.WebMap.Host; using Mobilize.WebMap.Server; using Mobilize.WebMap.Server.ObservableBinder; using Newtonsoft.Json.Serialization; using TestingDemo; /// /// Startup /// public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddWebMap(); services.RegisterModelMappers(); services.RegisterWrappers(); AddDesktopCompatibilityPlatform(services, entry); services.AddHttpContextAccessor(); services.AddDistributedMemoryCache(); services.AddSession(); services.AddAntiforgery(options => options.HeaderName = WebMapHeaders.AntiforgeryToken); services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new ObservableModelBinderProvider()); options.ModelMetadataDetailsProviders.Insert(0, new SuppressChildValidationMetadataProvider(typeof(IObservable))); }).AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); // If using IIS: services.Configure<IISServerOptions>(options => { options.AllowSynchronousIO = true; }); // If using Kestrel: services.Configure<KestrelServerOptions>(options => { options.AllowSynchronousIO = true; }); services.AddHealthChecks(); services.AddSignalR(); } private static void AddDesktopCompatibilityPlatform(IServiceCollection services, EntryPoint entryPoint) { services.AddScoped<ICommandFactory, CommandFactory>(); services.AddScoped<IApplication>((provider) => new ExtApplication(provider) { EntryPoint = entryPoint }); services.AddTransient<IBackgroundWorkerManager, BackgroundWorkerManager>(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDefaultFiles(); app.UseStaticFiles(); app.UseSession(); app.UseAntiforgeryToken(); app.UseWebMap(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("DefaultApi", "api/{controller}/{id}"); endpoints.MapHealthChecks("/health"); endpoints.MapHub<SignalHub>("/bgw"); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } } } }
Last updated
Was this helpful?