/Westwind.AspNetCore

ASP.NET Core Helpers and Utilities

Primary LanguageC#

Westwind.AspNetCore

Utility library providing useful helpers, formatters and extensions for ASP.NET Core

NuGet Pre Release

This is a small helper package that provides a number of small helper and extension classes that facilitate common operations in ASP.NET Core and MVC applications.

For documentation on sub-components please see their respective folders:

Installation

You can install the package from NuGet in Visual Studio:

Westwind.AspnetCore Package

PM> install-package westwind.aspnetcore

or the dotnet command line:

dotnet add package westwind.aspnetcore

Westwind.AspnetCore.Markdown Package

There is also a separate package for Westwind.AspNetCore.Markdown which provides a Markdown TagHelper and Markdown Parsing services:

PM> install-package westwind.aspnetcore.markdown

or the dotnet command line:

dotnet add package westwind.aspnetcore.markdown

Features

Api Functionality

  • Api Error Handling Filter
    A custom API error filter implementation that returns API responses on exceptions. Also provides a standardized ApiExecption class that can be used to force responses with specific HTTP response codes.

  • RawRequest Body String Formatter
    API formatter that allows for receiving raw non-json content to string and byte[] parameters, which otherwise isn't supported by MVC's API implementation. More info in blog post.

MVC Functionality

  • BaseController and BaseViewModel implementation
    A common base controller class that adds support for an auto-initialized BaseViewModel from which other VMs can inherit. Allows for automatic initialization of common features like ErrorDisplay or

  • AppUser ClaimsPrincipal and Cookie Authentication Helper
    A AppUser class that wraps a ClaimsPrincipal and makes it easier to add and retrieve claims as well as easily login and logout all from a single helper object.

  • Bootstrap Alert ErrorDisplay Tag Helper and Controller Support Feature
    In most MVC applications you need some sort of error display and this ErrorDisplay TagHelper makes it quick easy to display an Alert box from a custom ErrorDisplayModel input. Helper methods like ShowError() or ShowInfo() on BaseViewModel make it very easy to display error and informational messages on pages.

General ASP.NET Core

  • HttpRequest Extensions
    • GetBodyStringAsync() and GetRawBodyBytesAsync() - retrieve raw non-JSON content
    • MapPath() - Map virtual path to physical path on disk
    • Params() - Return an item from Form, Query or Session collections.