Skip to content

Instantly share code, notes, and snippets.

Aman Agrawal explorer14

Block or report user

Report or block explorer14

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SimplerActionFilter.cs
public class ModelBindingFailureFilterSimple : IActionFilter
{
public void OnActionExecuted(ActionExecutedContext context)
{
}
public void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
View Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(x => x.Filters.Add(new ModelBindingFailureFilter()));
}
View ModelValidationFilter.cs
public class ModelBindingFailureFilter : IActionFilter
{
public void OnActionExecuted(ActionExecutedContext context)
{
}
public void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
View ExceptionExtensions.cs
public static class ExceptionExtensions
{
public static string Details(this Exception exception)
{
StringBuilder builder = new StringBuilder();
builder.AppendLine(exception.Message);
while (exception.InnerException != null)
{
builder.AppendLine(exception.InnerException.Message);
View ValidationProblemDetails.cs
public class ValidationProblemDetails : ProblemDetails
{
public ValidationProblemDetails() : base()
{
}
public ValidationProblemDetails(
ModelStateDictionary modelStateDictionary)
: base()
{
View ProblemDetails.cs
public class ProblemDetails
{
public ProblemDetails()
{
}
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "type")]
public string Type { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "title")]
View Build.cake.cs
#tool "nuget:?package=OctopusTools"
#addin nuget:?package=Cake.SemVer
#addin nuget:?package=semver&version=2.0.4
using System;
using System.Net.Http;
using Newtonsoft.Json;
using System.IO;
var target = Argument("target", "Build");
View VanillaHealthCheckMiddleware.cs
public void Configure(
IApplicationBuilder app,
IHostingEnvironment env)
{
app.UseHealthChecks("/health/status");
// rest of the pipeline
}
View DDQuery.json
{
"requests": [
{
"q": "avg:myapp.app.ishealthy{$environment}",
"type": "bars",
"style": {
"palette": "dog_classic",
"type": "solid",
"width": "normal"
},
View DataDogMetricStructure.json
{ "series" :
[
{
"metric":"myapp.app.ishealthy",
"points":[[1545526632, 1]],
"type":"count",
"tags":"Environment:Production"
}
]
}
You can’t perform that action at this time.