User Manual

Initialize Endpoints

Method 1 - .NET MVC Projects without WebApi

To initialize the Mapzania endpoints, add the highlighted code to the Application_Start method in your global.asax file:


protected void Application_Start()
{
	Mapzania.Services.Start(this);
	AreaRegistration.RegisterAllAreas();
	FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
	Mapzania.Services.RegisterRoutes(GlobalConfiguration.Configuration);
	RouteConfig.RegisterRoutes(RouteTable.Routes);
	BundleConfig.RegisterBundles(BundleTable.Bundles);
}

Method 2 - .NET MVC Projects with WebApi

To initialise the Mapzania endpoints, add the highlighted code to the Register method in your WebApiConfig.cs file (located in the App_Start folder):


public static void Register(HttpConfiguration config)
{
	config.MapHttpAttributeRoutes();
	Mapzania.Services.RegisterRoutes(config);
	config.Routes.MapHttpRoute(
		name: "DefaultApi",
		routeTemplate: "api/{controller}/{id}",
		defaults: new { id = RouteParameter.Optional }
	);
}

Build your application.

To test that the endpoints have been added successfully, try this url on your site: http://[your site]/mz/maps. If the endpoint is working successfully, you should see JSON data.

NOTE: The initialization calls made in your global.asax or WebApiConfig.cs file may differ slightly from the examples above.

This is not serious.

What is vital that you place this line after you map the http routes (by calling config.MapHttpAttributeRoutes()) and before you define your default route (by calling config.Routes.MapHttpRoute). If this is not done, the Mapzania endpoints may not initialize correctly.

See the REST Documentation for more details on the endpoints that are now available in your project.