Raz.HeaderAttribute
1.0.0
See the version list below for details.
dotnet add package Raz.HeaderAttribute --version 1.0.0
NuGet\Install-Package Raz.HeaderAttribute -Version 1.0.0
<PackageReference Include="Raz.HeaderAttribute" Version="1.0.0" />
paket add Raz.HeaderAttribute --version 1.0.0
#r "nuget: Raz.HeaderAttribute, 1.0.0"
// Install Raz.HeaderAttribute as a Cake Addin
#addin nuget:?package=Raz.HeaderAttribute&version=1.0.0
// Install Raz.HeaderAttribute as a Cake Tool
#tool nuget:?package=Raz.HeaderAttribute&version=1.0.0
RazHeaderAttribute
Simple dotnet package for getting values from request headers in a clean way
Instructions
Setting up and using this library/package can be done in a few simple steps
Install from nuget
You can do this using one of two ways
Via nuget package manager console
Simply type in the following command in the PM console
Install-Package Raz.HeaderAttribtue
Via nuget package manager GUI
- Right click on your solution
- click on the nuget package manager
- search for Raz.HeaderAttribute
- install 😃
Add the Attribute close to the controller parameter you wish to bind it to
If you're already familiar with binding attributes this will be the simplest step. If you're not, C# has binding attributes that tell the framework where to get parameters specified in your controller from. For example, the
[FromUri]
attribute that tells the framework to pick that parameter from the URI or the[FromBody]
one that tells the framework to pick the parameter from the request body for post requests.This package makes the attribute
[FromHeader]
available and also lets us specify the name of the header key we need and just like the pre-built attributes, it tries to bind to any primitive data type specified. Here's an example:... using RazHeaderAttribute.Attributes; [Route("api/{controller}")] // Ewa-agoyin with sauce ;) public class YamAndBeansController : ApiController { ... // GET api/yamandbeans [HttpGet] public IEnumerable<string> Get([FromHeader("page")] int page, [FromHeader("rows")] string row) { // Print in the debug window to be sure our bound stuff are passed :) Debug.WriteLine($"My Debugger!!! Arrrrrggggh!!!!: Rows {rows}, Page {page}"); ... } }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Microsoft.AspNet.WebApi.Client (>= 5.2.3)
- Microsoft.AspNet.WebApi.Core (>= 5.2.3)
- Newtonsoft.Json (>= 6.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Added FromHeader Attribute