Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
@joshuaflanagan
joshuaflanagan / package.bat
Created June 24, 2011 02:57
Examples of how to build all Nuget nuspec files in a folder
@ECHO OFF
SETLOCAL
SET VERSION=%1
SET NUGET=buildsupport\nuget.exe
FOR %%G IN (packaging\nuget\*.nuspec) DO (
%NUGET% pack %%G -Version %VERSION% -Symbols -o artifacts
)
@iamkoch
iamkoch / DependencyInjection.cs
Created April 9, 2012 16:41
Register all assemblies in MVC Bin folder for Castle.Windsor DI
using System;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using WednesdayFootball.Factory;
@colinangusmackay
colinangusmackay / List-tables-as-wiki-markup.sql
Created July 2, 2012 21:35
A T-SQL script that renders media wiki markup of a list of tables or views that can be used in the creation of a data dictionary. More details on my blog: http://colinmackay.co.uk/2012/06/14/creating-a-data-dictionary-with-sql-server-and-mediawiki-part-on
-- For more information about this script and its uses, visit:
-- http://colinmackay.co.uk/2012/06/14/creating-a-data-dictionary-with-sql-server-and-mediawiki-part-one-a-list-of-tables/
DECLARE @Type NVARCHAR(100) = 'BASE TABLE' -- 'VIEW' OR 'BASE TABLE'
DECLARE @catalogue SYSNAME;
DECLARE @schema SYSNAME;
DECLARE @name SYSNAME;
SET NOCOUNT ON
@KevM
KevM / log-examples.txt
Created October 5, 2012 14:35
Adding the current web request URL to your log4net logging context
2012-10-04 17:25:25,241 DEBUG [|24] Dovetail.SDK.Bootstrap.Clarify.CurrentSDKUser / Setting the current user to be annie
2012-10-04 17:25:25,246 DEBUG [annie|24] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache / Get session for annie. Found valid session in cache.
2012-10-04 17:25:39,695 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache /api/history/case/148 Getting application session.
2012-10-04 17:25:39,695 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache /api/history/case/148 Get session for sa. Found valid session in cache.
2012-10-04 17:25:39,695 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache /api/history/case/148 Get session for annie. Found valid session in cache.
2012-10-04 17:25:39,696 DEBUG [|28] Dovetail.SDK.Bootstrap.Authentication.PrincipalFactory /api/history/case/148 Creating principal for user annie with 165 permissions.
2012-10-04 17:25:39,696 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.CurrentSDKUser /api/history/case/148 Setting the curren
@mahizsas
mahizsas / vs2012-empty.sln
Last active October 14, 2015 00:28 — forked from lucamilan/gist:3841570
VS2012 Empty Solution File
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@mahizsas
mahizsas / DbContext.cs
Created April 5, 2013 07:05
Flat DbEntityValidationException errors
public override int SaveChanges()
{
try
{
return base.SaveChanges();
}
catch (DbEntityValidationException ex)
{
// Retrieve the error messages as a list of strings.
var errorMessages = ex.EntityValidationErrors
@rarous
rarous / Maybe.cs
Last active December 16, 2015 01:29
using System;
using System.Collections.Generic;
using System.Linq;
public interface Maybe<T> { }
public class Nothing<T> : Maybe<T> { }
public class Just<T> : Maybe<T> {
public T Value { get; private set; }
public static class HtmlExtensions
{
public static IHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, Dictionary<string, IEnumerable<SelectListItem>> selectList)
{
/*
* <select name="tmodel">
* <optgroup title="Items">
* <option value="item">Item</option>
* </select>
*/
@mhinze
mhinze / BaseController.cs
Created November 19, 2013 19:43
BaseController.cs with Async
using System.Threading.Tasks;
using System.Web.Mvc;
using JetBrains.Annotations;
using ShortBus;
public abstract class BaseController : Controller
{
public IMediator Mediator { get; set; }
protected Response<TResult> Query<TResult>(IQuery<TResult> query)

Owin Authentication with Web API 2

Using Microsoft.Owin.Security along with .NET Web API 2 for authentication on Single Page Applications.

My example is split up into 2 different projects, API which is WebAPI2 project and MyProj which is a basic MVC that contains primarily only JavaScript/CSS/etc and the startup classes.

API > AccountController.cs

namespace API

{