WebMAP From Scratch

When your code is converted, WebMAP performs any necessary changes to start using WebMAP right away.

But if you want to install it from scratch follow these steps:

Using VS 2019

  1. Start Visual Studio 2019

  2. Select File\New\Project...

  3. On the New Project dialog:

    1. Select C# option from Languages box

    2. Select Web From All project types box

  4. Choose ASP.NET Core Web Application

  5. Press Next

  6. Insert your Web Application name

  7. Press Create

  8. On the New ASP.NET Core Web Application choose Empty and press Create

  9. Add the following NuGets:

    • Microsoft.AspNetCore.All

    • Mobilize.Weaving.WebMAPExtensions.All

    • Mobilize.WebMAP.CoreServices.All

    • Mobilize.WebMAP.BundleBasic.All

  10. Modify your Startup.cs to look like the following:

    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();
                }
            }
        }
    }

The entry point for the application can be set when adding the DCP, for example:

  1. (Optional) Add a Registrations.cs file like the following:

  2. That's all. Your application is ready to start using WebMAP.

Last updated

Was this helpful?