Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Issue: Simplify ASP.Net WebApi Configuration Setup [906]

$
0
0
Currently to configure ASP.Net WebApi a default route is required.

Propose that an convenience extension method be added that create a default route with a default path e.g.

GlobalConfiguration.Configuration.AutoRegisterDefaultWebApi();

With an implementation along the lines of

namespace System.Web.Http
{
public static class WebApiConfigurationExtensions
{
public static void AutoRegisterDefaultWebApi(this HttpConfiguration config, string basePath = "api")
{
//TODO: Check if base path has trailing slash
//TODO: Handle base path is null or empty

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: basePath + "/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

//TODO: Future enhancements team think should be doing by default
}
}
}


General notes/thoughts:
1) It may be easier for new users to find this config if they import into an existing project (e,g. via NuGet)
2) Could provide extension point to apply other defaults in the future.
3) Could be useful for unit tests to apply quickly apply default config
4) Could be useful for self hosting situtations for easy setup



Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>