/Simplify.Web.Multipart

Simplify.Web multipart form model binder

Primary LanguageC#GNU Lesser General Public License v3.0LGPL-3.0

Simplify.Web.Multipart

Nuget Version Nuget Download Build Package Libraries.io dependency status for latest release CodeFactor Grade Platform

Simplify.Web.Multipart is a package which provides multipart form view model and model binder for Simplify.Web web-framework.

Quick start

Registering binder

public void Configuration(IApplicationBuilder app)
{
    // ...existing code...
    HttpModelHandler.RegisterModelBinder<HttpMultipartFormModelBinder>();
    // ...existing code...
    app.UseSimplifyWeb();
}

public void ConfigureServices(IServiceCollection services)
{
    // ...existing code...
    DIContainer.Current.RegisterHttpMultipartFormModelBinder();
    // ...existing code...
}

Getting files from client

Asynchronous

public class MyController : ControllerAsync<MultipartViewModel>
{
    public override async Task<ControllerResponse> Invoke()
    {
        await ReadModelAsync();

        Model.Files;
    }
}

Synchronous

Multipart files will be deserialized to the controller model on first model access

public class MyController : Controller<MultipartViewModel>
{
    public override ControllerResponse Invoke()
    {
        Model.Files;
    }
}