Skip to content

Instantly share code, notes, and snippets.

@kenstone
kenstone / _AppStart.cshtml
Created August 21, 2012 21:24
MVC 4 Application Start Code
@{
if (!WebSecurity.Initialized)
{
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId",
"UserName", autoCreateTables: true);
}
}
@kenstone
kenstone / gist:3629483
Created September 5, 2012 02:39
Knockout View Model Method Call without deferreds
var viewModel = function() {
var self = this;
self.description = ko.observable('hello');
self.get = function(words) {
$.ajax({
url: "/echo/json",
dataType: "json",
type: "POST",
@kenstone
kenstone / gist:3629588
Created September 5, 2012 02:56
Knockout View Model Method Call with deferreds
var viewModel = function() {
var self = this;
self.description = ko.observable();
self.get = function(words) {
return $.ajax({
url: "/echo/json",
dataType: "json",
type: "POST",
.flex() {
display: -webkit-box;
display: -moz-box;
display:-webkit-flex;
display: -ms-flexbox;
display:flex;
}
.flex-justify(@justifyStyle) {
@kenstone
kenstone / FailRequestAttribute.cs
Created September 19, 2012 16:46
FailRequestAttribute
using System;
using System.Net;
using System.Threading;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Controllers;
using ActionFilterAttribute = System.Web.Http.Filters.ActionFilterAttribute;
namespace MyProject
@kenstone
kenstone / aspnet45 auth table defintions.sql
Created August 21, 2012 21:08
SQL Table definitions for ASP.NET 4.5 Simple Membership Authentication
CREATE TABLE [dbo].[UserProfile] (
[UserId] INT IDENTITY (1, 1) NOT NULL,
[UserName] NVARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([UserId] ASC)
);
CREATE TABLE [dbo].[webpages_Membership] (
[UserId] INT NOT NULL,
[CreateDate] DATETIME NULL,
[ConfirmationToken] NVARCHAR (128) NULL,