Westwind.AspNetCore
4.0.12
See the version list below for details.
dotnet add package Westwind.AspNetCore --version 4.0.12
NuGet\Install-Package Westwind.AspNetCore -Version 4.0.12
<PackageReference Include="Westwind.AspNetCore" Version="4.0.12" />
paket add Westwind.AspNetCore --version 4.0.12
#r "nuget: Westwind.AspNetCore, 4.0.12"
// Install Westwind.AspNetCore as a Cake Addin #addin nuget:?package=Westwind.AspNetCore&version=4.0.12 // Install Westwind.AspNetCore as a Cake Tool #tool nuget:?package=Westwind.AspNetCore&version=4.0.12
Westwind.AspNetCore
Utility library providing useful helpers, formatters and extensions for ASP.NET Core
This is a small package that provides a number of convenience helper and extension classes that facilitate common operations in ASP.NET Core API and MVC applications and ASP.NET Core in general.
You can use this package as is or use the source code to pick and choose pieces to add to your own applications - most features are self-contained and easily moved and integrated.
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
Documentation
A class reference for the library can be found here:
Features
General ASP.NET Functionality
FormVariableBinding unbinds forms to an Object
Request.Form
unbind routine that allows you to unbind form variables into an existing object only updating properties that are are available in the request form context. This can in many instances be much easier to use than Model binding which creates new objects and so requires tracking changes.Custom Http Headers Middleware
Allows adding and removing of HTTP headers to every request using middleware configuration. It's a missing piece in the ASP.NET Core base libraries.HttpRequest Extensions
GetBodyStringAsync()
andGetRawBodyBytesAsync()
- retrieve raw non-JSON contentGetUrl()
- Returns the Absolute URL for the current request.Params()
- Return an item from Form, Query or Session collections.IsFormVar()
- Determines if a Form variable existsIsPostback()
- Determines if request is a Post/Put operationIsLocal
- Determines if the current URL is a local machine URLUnbindFormVars()
- unbinds form vars into an object (uses FormVariable Binder)
HttpContext Extensions
MapPath()
- Map virtual path to physical path on diskResolvePath()
- resolves a relative path to a fully qualified site path (~/, /)SetUserLocale()
- lets you easily set User locale and UiLocale for a request
DataProtector Wrapper
Helper to make it easier to use the DataProtector API to create secure tokens.UserState Helper
The UserState object greatly simplifies working with auth 'cached' user data that can be stored across requests. Useful for caching things like username, main IDs to reduce data base lookups or simply to carry global values across requests. Data is stored either in an Identity Claim or a custom encrypted cookie. The class supports easily serialization and auto-loading and saving. Can be extended by subclassing and adding your own custom properties to track beyond several common ones.WeUtils
EncodeJsString()
- string encoding for Json without library requirementsDecodeJsString()
- string decoding for Json without library requirementsEncodeJsDate()
- data encoding for Json without library requirements
Gravatar
Gravatar
class that quickly lets you embed aGravatarLink()
andGravatarImage()
into pages.
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 and Base View models.ViewRenderer
Render Razor/MVC view output to a string using a controller context.AppUser ClaimsPrincipal and Cookie Authentication Helper
AAppUser
class that wraps aClaimsPrincipal
and makes it easier to add and retrieve claims as well as easily login and logout all from a single helper object.Razor Error Display Component based on Bootstrap Alert
Provides an<error-display>
razor component that you model bind directly, or you can use the built inErrorDisplayModel
on theBaseViewModel
class in overloaded ViewModel components of your own.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 likeShowError()
,ShowSuccess()
orShowInfo()
onBaseViewModel
make it very easy to display error and informational messages on pages, consistently
Api Functionality
BaseApiController API base class that includes exception trapping and display and can be used with UserState that is passed through requests from Auth tokens or other custom auth mechanism. Similar to BaseControl but optimized for API operation.
ApiExceptionFilter Error Handling and ApiException
A custom API error filter implementation that returns JSON API responses on exceptions. Also provides a standardizedApiExecption
class that can be used to easily throw exceptions that returns specific HTTP response codes.Api Base Response Object
ApiResponse
base class that can be used to return consistent API results that include error status, error message, status code as well as the actual data. Both typed and untyped versions.RawRequest Body String Formatter
API formatter that allows for receiving raw non-json content tostring
andbyte[]
parameters, which otherwise isn't supported by MVC's API implementation. More info in blog post.User Token Manager
Moved to Westwind.Utilities.Data
A database driven token manager that can create, store, validate and manage the life time of short lived generated tokens. Useful for creating tokens that are assigned after an initial authentication and then used for API access.JWT Helper Make it easier to create JWT Tokens in the ASP.NET Auth configuration
General ASP.NET Core
License
The Westwind.Web.MarkdownControl library is an open source product licensed under:
All source code is © West Wind Technologies, regardless of changes made to them. Any source code modifications must leave the original copyright code headers intact if present.
There's no charge to use, integrate or modify the code for this project. You are free to use it in personal, commercial, government and any other type of application and you are free to modify the code for use in your own projects.
Give back
If you find this library useful, consider making a small donation:
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BA3NHHFHTMXD8" title="Find this library useful? Consider making a small donation." alt="Make Donation" style="text-decoration: none;"> <img src="https://weblog.west-wind.com/images/donation.png" /> </a>
Update History
Version 4.0
Physically removed UserTokenManager from the package (seev3.20
for initial deprecation).Version 3.20
Removed the UserTokenManager class from this package and moved it into Westwind.Utilities.Data in order to remove the default footprint for the SQL libraries from this package.
Breaking Changes
The structure of the UserTokens table for UserTokenManager
has changed with some additional fields. The table has to be updated to include additional fields. If your DB has write access for the connection string you can delete the table and let it rebuild. Otherwise look at the UserTokenManager.CreateUserTokenSqlTable()
method for the latest structure and SQL statement.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- System.IdentityModel.Tokens.Jwt (>= 8.6.1)
- Westwind.Utilities (>= 5.1.6.2)
-
net9.0
- System.IdentityModel.Tokens.Jwt (>= 8.6.1)
- Westwind.Utilities (>= 5.1.6.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Westwind.AspNetCore:
Package | Downloads |
---|---|
Tyle_Evmos
Package Description |
|
Tyle.Nft
Package Description |
|
TyleCSC
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.14 | 126 | 3/9/2025 |
4.0.12 | 204 | 3/7/2025 |
4.0.9 | 196 | 3/6/2025 |
4.0.7 | 1,413 | 8/4/2024 |
4.0.6 | 111 | 7/27/2024 |
4.0.5 | 247 | 7/18/2024 |
4.0.4 | 281 | 6/26/2024 |
4.0.3 | 511 | 4/28/2024 |
4.0.2 | 1,063 | 2/17/2024 |
4.0.1 | 143 | 2/15/2024 |
4.0.0 | 155 | 2/10/2024 |
3.20.0 | 316 | 2/10/2024 |
3.11.0 | 147 | 2/6/2024 |
3.9.2 | 132 | 1/19/2024 |
3.9.0 | 269 | 11/30/2023 |
3.8.7 | 1,866 | 8/15/2023 |
3.8.5 | 619 | 6/10/2023 |
3.7.0 | 4,371 | 12/12/2022 |
3.6.3 | 747 | 10/6/2022 |
3.6.2 | 549 | 9/18/2022 |
3.6.0 | 481 | 9/11/2022 |
3.5.5 | 2,861 | 7/6/2022 |
3.5.2 | 679 | 6/19/2022 |
3.5.1 | 497 | 6/17/2022 |
3.4.5 | 12,253 | 8/27/2021 |
3.4.3 | 849 | 3/9/2021 |
3.4.2 | 439 | 3/8/2021 |
3.4.0 | 442 | 2/12/2021 |
3.2.15 | 5,684 | 2/25/2020 |
3.2.9 | 1,720 | 6/6/2019 |
3.2.8 | 828 | 5/2/2019 |
3.2.1 | 140 | 2/10/2024 |
3.2.0 | 1,818 | 12/7/2018 |
3.0.38 | 1,104 | 9/6/2018 |
3.0.30 | 1,006 | 9/2/2018 |
3.0.29 | 1,141 | 7/23/2018 |
3.0.18 | 1,264 | 4/5/2018 |
3.0.15 | 1,103 | 2/18/2018 |
3.0.14 | 1,201 | 2/14/2018 |
3.0.12 | 1,238 | 1/28/2018 |
3.0.11 | 1,188 | 1/26/2018 |
0.1.0 | 1,117 | 10/4/2017 |