This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//On start up : | |
MvcHandler.DisableMvcResponseHeader = true; | |
// as an http module/global asax | |
protected void Application_PreSendRequestHeaders(object sender, EventArgs e) | |
{ | |
// Remove the "Server" HTTP Header from response - security review recommends against sending this | |
var app = sender as HttpApplication; | |
if (app == null || null == app.Context) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .NET/CLR app domains | |
// You - always want to be logging these errors! | |
AppDomain.CurrentDomain.UnhandledException += (s,e) => {}; | |
// Framework specific handlers | |
System.Windows.Application.Current.DispatcherUnhandledException += (s,e) => {}; // WPF | |
System.Windows.Forms.Application.ThreadException += (s,e) => {}; // Windows Forms | |
System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (s,e) => {}; // TPL - not really very imporant | |
// ASP.NET (i'm guessing you hook into this in your Global.asx?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var customMatchers = { | |
toInclude: function (util, customEqualityTesters) { | |
return { | |
compare: function (actual, expected) { | |
if (expected === undefined) { | |
expected = ''; | |
} | |
var result = { | |
message: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CmsController : BootstrapBaseController | |
{ | |
private readonly PrismicProxy _prismicProxy; | |
public CmsController(PrismicProxy prismicProxy) | |
{ | |
_prismicProxy = prismicProxy; | |
} | |
public ActionResult Dynamic(string id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using Xunit; | |
namespace MyNameSpace.Tests | |
{ | |
public class CacheTests | |
{ | |
[Fact] | |
public void CanReuseCachedObject() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.Owin; | |
using Owin; | |
using OwinSpike.Simple.Console; | |
//Console app | |
//NuGet packages : | |
//<package id="Microsoft.Owin.SelfHost" version="3.0.0" targetFramework="net45" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.IdentityModel.Tokens; | |
using System.Web.Mvc; | |
using System.Web.Optimization; | |
using System.Web.Routing; | |
using Microsoft.Owin; | |
using Microsoft.Owin.Security.Cookies; | |
using Microsoft.Owin.Security.OpenIdConnect; | |
using OauthScratch.MvcOwinClient; | |
using Owin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using log4net.Appender; | |
using log4net.Core; | |
using log4net.Layout; | |
namespace RestTest.Logging | |
{ | |
public static class Log4NetAppenderFactory | |
{ | |
private static readonly PatternLayout PatternLayout = new PatternLayout("[%-5level][%date][%thread][%logger]: %message%newline"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<Reference><RuntimeDirectory>\System.Net.Http.dll</Reference> | |
<NuGetReference>Microsoft.AspNet.WebApi.OwinSelfHost</NuGetReference> | |
<Namespace>Microsoft.Owin.Hosting</Namespace> | |
<Namespace>Owin</Namespace> | |
<Namespace>System.Web.Http</Namespace> | |
<Namespace>System.Net.Http</Namespace> | |
<Namespace>System.Net</Namespace> | |
</Query> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
namespace YourWebsite.Filters | |
{ | |
public class ObjectNotFoundExceptionFilterAttribute : ActionFilterAttribute, IExceptionFilter | |
{ | |
public void OnException(ExceptionContext filterContext) | |
{ | |
if (filterContext.Exception is NHibernate.ObjectNotFoundException) | |
{ |
OlderNewer