Commit e98c45ad authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+22 −0
Changes for Building Web APIs with ASP.NET 4.5 - Working Files/Chapter 1/Areas/HelloApi.sln: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloApi", "HelloApi\HelloApi.csproj", "{DACFD2C1-8C5A-4DBA-9B8E-4C2BBF3EA094}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{DACFD2C1-8C5A-4DBA-9B8E-4C2BBF3EA094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{DACFD2C1-8C5A-4DBA-9B8E-4C2BBF3EA094}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{DACFD2C1-8C5A-4DBA-9B8E-4C2BBF3EA094}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{DACFD2C1-8C5A-4DBA-9B8E-4C2BBF3EA094}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal
+28 −0
Changes for Building Web APIs with ASP.NET 4.5 - Working Files/Chapter 1/Areas/HelloApi/App_Start/BundleConfig.cs: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System.Web;
using System.Web.Optimization;

namespace HelloApi
{
    public class BundleConfig
    {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/respond.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/site.css"));
        }
    }
}
+13 −0
Changes for Building Web APIs with ASP.NET 4.5 - Working Files/Chapter 1/Areas/HelloApi/App_Start/FilterConfig.cs: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System.Web;
using System.Web.Mvc;

namespace HelloApi
{
    public class FilterConfig
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }
    }
}
+45 −0
Changes for Building Web APIs with ASP.NET 4.5 - Working Files/Chapter 1/Areas/HelloApi/App_Start/IdentityConfig.cs: 45 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using HelloApi.Models;

namespace HelloApi
{
    // Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application.

    public class ApplicationUserManager : UserManager<ApplicationUser>
    {
        public ApplicationUserManager(IUserStore<ApplicationUser> store)
            : base(store)
        {
        }

        public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
        {
            var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator<ApplicationUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit = true,
                RequireLowercase = true,
                RequireUppercase = true,
            };
            var dataProtectionProvider = options.DataProtectionProvider;
            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
            }
            return manager;
        }
    }
}
+23 −0
Changes for Building Web APIs with ASP.NET 4.5 - Working Files/Chapter 1/Areas/HelloApi/App_Start/RouteConfig.cs: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace HelloApi
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
Loading