Similar to ASP.NET Core 2.1's AddMvc()
, Unravel provides an AddAspNetMvc()
extension method on IServiceCollection
that registers a System.Web.Mvc.IDependencyResolver
.
The resulting IAspNetMvcBuilder
is similar to IMvcBuilder
, providing an extension point for additional configuration:
public override void ConfigureServices(IServiceCollection services)
{
services.AddAspNetMvc()
.AddControllersAsServices();
}
Also similar to ASP.NET Core 2.1, AddAspNetMvc()
accepts an optional Action<MvcOptions>
to consolidate configuration, including:
.AddAspNetMvc(options =>
{
// Equivalent to AreaRegistration.RegisterAllAreas()
options.RegisterAllAreas();
// Equivalent to MvcHandler.DisableMvcResponseHeader
options.DisableMvcResponseHeader = true;
// Equivalent to GlobalFilters.Filters.Add(...)
options.Filters.Add(...);
// Equivalent to ModelBinders.Binders.Add(...)
options.ModelBinders.Add(...);
// Equivalent to RouteTable.Routes.MapRoute(...);
options.Routes.MapRoute(...);
})
AddAspNetMvc()
registers a model binder for IFormFile
, to replace references to
System.Web.HttpPostedFileBase
.
Some IFormFile
properties are not supported, due to HttpPostedFileBase
limitations.