Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.97 KB

README.md

File metadata and controls

46 lines (32 loc) · 1.97 KB

Unravel.AspNet.Mvc

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

MvcOptions

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

IFormFile Model Binder

AddAspNetMvc() registers a model binder for IFormFile, to replace references to System.Web.HttpPostedFileBase.

Some IFormFile properties are not supported, due to HttpPostedFileBase limitations.