Skip to content

emalfroy/guid-header-modelbinding

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Be.Vlaanderen.Basisregisters.AspNetCore.Mvc.ModelBinding.GuidHeader Build Status

An MVC ModelBinder for GUID type or GUID as string, which also looks in the header.

Usage

[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public class FromCommandIdAttribute : Attribute, IModelNameProvider, IBinderTypeProviderMetadata
{
    public BindingSource BindingSource => BindingSource.Header;

    public string Name => "CommandId";

    public Type BinderType => typeof(GuidHeaderModelBinder);
}

Controller

public async Task<IActionResult> Post(
            [FromCommandId] Guid commandId,
            [FromBody] ...,
            CancellationToken cancellationToken)
{
    ...
}

About

An MVC ModelBinder for GUID type or GUID as string, which also looks in the header.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 50.1%
  • F# 42.1%
  • Shell 7.8%