Class NeonController
Enhances the Controller class to simplify and enhance web application logging. Use this as the base class for ASP.NET UX applications.
Namespace: Neon.Web
Assembly: Neon.Web.dll
Syntax
[TypeFilter(typeof(LoggingExceptionFilter))]
public abstract class NeonController : Controller
Remarks
This class includes the Logger property which returns a logger that can be used for logging controller events. This logger will have it's module set to WEB-CONTROLLER-NAME and can be used as a simplier alternative to doing dependency injection to your controller's constructor.
Constructors
NeonController()
Constructor.
Declaration
protected NeonController()
Properties
Logger
Returns the controller's logger.
Declaration
public ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Methods
Requires(bool, string, string, HttpStatusCode)
Throws a HttpApiException when condition
is false
.
Declaration
public void Requires(bool condition, string message = null, string errorCode = null, HttpStatusCode statusCode = HttpStatusCode.BadRequest)
Parameters
Type | Name | Description |
---|---|---|
bool | condition | The condition being checked. |
string | message | Optionally specifies a human readable message. |
string | errorCode | Optionally specifies a computer readable error code string. |
HttpStatusCode | statusCode | Optionally specifies the HTTP status code. This defaults to BadRequest. |
Remarks
note
errorCode
is restricted to 1-32 characters including ASCII letters, digits,
undercores, dots, or dashes.
Exceptions
Type | Condition |
---|---|
HttpApiException | Thrown when |
Requires(Func<bool>, string, string, HttpStatusCode)
Throws a HttpApiException when the predicate
function returns false
.
Declaration
public void Requires(Func<bool> predicate, string message = null, string errorCode = null, HttpStatusCode statusCode = HttpStatusCode.BadRequest)
Parameters
Type | Name | Description |
---|---|---|
Func<bool> | predicate | Called to retrieve the condition value. |
string | message | Optionally specifies a human readable message. |
string | errorCode | Optionally specifies a computer readable error code string. |
HttpStatusCode | statusCode | Optionally specifies the HTTP status code. This defaults to BadRequest. |
Remarks
note
errorCode
is restricted to 1-32 characters including ASCII letters, digits,
undercores, dots, or dashes.
Exceptions
Type | Condition |
---|---|
HttpApiException | Thrown when |
RequiresNotNull(object, string, string, HttpStatusCode)
Throws a HttpApiException when value
is null
.
Declaration
public void RequiresNotNull(object value, string name, string errorCode = null, HttpStatusCode statusCode = HttpStatusCode.BadRequest)
Parameters
Type | Name | Description |
---|---|---|
object | value | The object value being checked. |
string | name | Identifies the value being checked. |
string | errorCode | Optionally specifies a computer readable error code string. |
HttpStatusCode | statusCode | Optionally specifies the HTTP status code. This defaults to BadRequest. |
Remarks
note
errorCode
is restricted to 1-32 characters including ASCII letters, digits,
undercores, dots, or dashes.
Exceptions
Type | Condition |
---|---|
HttpApiException | Thrown when |
RequiresNotNull(string, string, string, HttpStatusCode)
Throws a HttpApiException when value
is null
or empty.
Declaration
public void RequiresNotNull(string value, string name, string errorCode = null, HttpStatusCode statusCode = HttpStatusCode.BadRequest)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string value being checked. |
string | name | Identifies the value being checked. |
string | errorCode | Optionally specifies a computer readable error code string. |
HttpStatusCode | statusCode | Optionally specifies the HTTP status code. This defaults to BadRequest. |
Remarks
note
errorCode
is restricted to 1-32 characters including ASCII letters, digits,
undercores, dots, or dashes.
Exceptions
Type | Condition |
---|---|
HttpApiException | Thrown when |