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
function api_test(url, type, data, callback) { | |
$.ajax( | |
{ | |
url: url, | |
type: type, | |
processData: false, | |
contentType: 'application/json; charset=utf-8', | |
data: JSON.stringify(data), | |
dataType: 'json', | |
async: 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
namespace MyNamespace { | |
public static class MyHelper | |
{ | |
public static MvcHtmlString MyHelper(this HtmlHelper helper) | |
{ | |
return helper.AntiForgeryToken(); | |
} | |
} | |
} |
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
Watcher: | |
(wood) Watch at least one repository | |
(bronze) Watcher more than 10 | |
(silver) Watcher more than 100 | |
(gold) Watcher more than 500 | |
Follower: | |
(wood) Follow at least one person | |
(bronze) Follow more than 10 people | |
(silver) Follow more than 100 people |
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 HostedByCheckAttribute : ActionFilterAttribute { | |
public override void OnActionExecuting(ActionExecutingContext filterContext) { | |
var postId = filterContext.ActionParameters["id"] as int; | |
var postsRepo = new PostsRepository(); | |
var post = postsRepo.Get(postId); | |
if (!post.IsHostedBy(/* ... */)) { | |
filterContext.Result = new ViewResult { ViewName = "InvalidOwner", ViewBag = filterContext.Controller.ViewBag, ViewData = filterContext.Controller.ViewData }; | |
} |
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 Attribute : ActionFilterAttribute { | |
public override void OnActionExecuted(ActionExecutedContext filterContext) { | |
base.OnActionExecuted(filterContext); | |
if (!filterContext.ExceptionHandled) { | |
var exception = filterContext.Exception; | |
if (exception is CustomException) { | |
filterContext.Controller.ViewData.ModelState.Add(String.Empty, Resource.CustomExceptionMessage); | |
} |
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 System.Diagnostics; | |
using System.IO; | |
// Please try to run both: Cassini and IIS. | |
// For IIS select Application Pool with Process Identity == Your identity |
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; | |
namespace MvcForDebug2.Infrastructure { | |
public class ServiceAttribute : ActionFilterAttribute { | |
public override void OnActionExecuted(ActionExecutedContext filterContext) { | |
if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) { |
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
<?xml version="1.0"?> | |
<configuration> | |
<system.web> | |
<httpHandlers> | |
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> | |
</httpHandlers> | |
<!-- | |
Enabling request validation in view pages would cause validation to occur |
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 interface IMapper<TInput, TOutput> | |
{ | |
TOutput Map(TInput input); | |
} | |
public interface ICompositeMapper<TInput, TOutput> | |
{ | |
TOutput[] Map(TInput input); | |
} |
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.Text; | |
using NUnit.Framework; | |
using NSubstitute; | |
using Moq; | |
namespace NewTools | |
{ |