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
private static readonly Dictionary<string, string> Provinces = new Dictionary<string, string>(){ | |
{"AG","Agrigento"}, | |
{"AL","Alessandria"}, | |
{"AN","Ancona"}, | |
{"AO","Aosta"}, | |
{"AR","Arezzo"}, | |
{"AP","Ascoli Piceno"}, | |
{"AT","Asti"}, | |
{"AV","Avellino"}, | |
{"BA","Bari"}, |
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
//This solution is based on the code of this tutorial https://github.com/louislewis2/AngularJSAuthentication | |
using Microsoft.AspNet.SignalR; | |
namespace Solution.Web.Providers | |
{ | |
public class QueryStringIdProvider : IUserIdProvider | |
{ | |
public string GetUserId(IRequest request) | |
{ | |
var token = request.QueryString.Get("access_token"); | |
var authenticationTicket = Startup.OAuthOptions.AccessTokenFormat.Unprotect(token); |
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 AsyncMediatorPipeline<TRequest, TResponse> : IAsyncRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse> | |
{ | |
private readonly IAsyncRequestHandler<TRequest, TResponse> inner; | |
private readonly IAsyncPreRequestHandler<TRequest>[] preRequestHandlers; | |
private readonly IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers; | |
public AsyncMediatorPipeline(IAsyncRequestHandler<TRequest, TResponse> inner, IAsyncPreRequestHandler<TRequest>[] preRequestHandlers, IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers) | |
{ | |
this.inner = inner; |
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.Runtime.CompilerServices; | |
using System.Diagnostics; | |
using log4net; | |
// TODO: you must move the below configuration call. | |
// It must be executed prior to any calls to Logger | |
// Application_Start or summat | |
log4net.Config.XmlConfigurator.Configure(); | |
public class CustomError |
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.Web; | |
using System.Web.Mvc; | |
using System.Diagnostics; | |
/// <summary> | |
/// A simple attribute that times controller actions, returning the measured time | |
/// in the HTTP header "X-Duration". | |
/// </summary> |
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
<%@ WebHandler Language="C#" Class="PassThruProxy" Debug="true" %> | |
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Text; | |
using System.Web; | |
public class PassThruProxy : IHttpHandler { | |
public PassThruProxy( ) { } |
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
Introduction | |
The code first fluent API is most commonly accessed by overriding the OnModelCreating method on your derived DbContext. The following samples are designed to show how to do various tasks with the fluent api and allow you to copy the code out and customize it to suit your model, if you wish to see the model that they can be used with as-is then it is provided at the end of this article. | |
Property Mapping | |
The Property method is used to configure attributes for each property belonging to an entity or complex type. The Property method is used to obtain a configuration object for a given property. The options on the configuration object are specific to the type being configured; IsUnicode is available only on string properties for example. |
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 ProxyHandler : IHttpHandler | |
{ | |
const string SERVER_URL = "http://dev-server"; | |
#region IHttpHandler Members | |
public bool IsReusable | |
{ | |
get { return false; } | |
} |
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
<system.webServer> | |
<httpProtocol> | |
<customHeaders> | |
<add name="Access-Control-Allow-Origin" value="*"/> | |
</customHeaders> | |
</httpProtocol> | |
</system.webServer> |
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.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
using StackExchange.Profiling; | |
namespace MiniProfiler.Razor { | |
public class ProfiledRazorViewEngine : RazorViewEngine { |