- WebAPIRc-noexe.zip
- WebAPIRc
- WebAPIRc.sln
- WebAPIRc.suo
- WebAPIRc
- App_Start
- bin
- Content
- Controllers
- favicon.ico
- Global.asax
- Global.asax.cs
- Helper
- Images
- accent.png
- ajax-loader.gif
- aspNetHome.png
- body-bottom-bg.png
- body-top-bg.png
- bullet.png
- container-bg.png
- facebook.png
- findHosting.png
- heroAccent.png
- NuGetGallery.png
- orderedList0.png
- orderedList1.png
- orderedList2.png
- orderedList3.png
- orderedList4.png
- orderedList5.png
- orderedList6.png
- orderedList7.png
- orderedList8.png
- orderedList9.png
- orderedListOne.png
- orderedListThree.png
- orderedListTwo.png
- texturetastic_gray.png
- twitter.png
- windowsLive.png
- Models
- packages.config
- Properties
- Scripts
- Views
- Web.config
- Web.Debug.config
- Web.Release.config
- WebAPIRc.csproj
- WebAPIRc.csproj.user
- WebAPIRc.zip
- WebAPI.zip
- WebAPI
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.Practices.Unity;
using WebAPI.Models;
namespace WebAPI
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class WebApiApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
protected void Application_Start()
{
RegisterDependencies();
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
BundleTable.Bundles.RegisterTemplateBundles();
}
private void RegisterDependencies()
{
IUnityContainer container = new UnityContainer();
container.RegisterInstance<IBookRepository>(new BookRepository());
GlobalConfiguration.Configuration.ServiceResolver.SetResolver(
t =>
{
try
{
return container.Resolve(t);
}
catch (ResolutionFailedException)
{
return null;
}
},
t =>
{
try
{
return container.ResolveAll(t);
}
catch (ResolutionFailedException)
{
return new List<object>();
}
});
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
A life-long-learner, maker and soft music fan. Likes building things to solve problems. Years of successful records serving mid and large scale .NET applications in domestic and international client environment. Expertise in different areas of software development life cycles and Software Architecture.
Always looks for new technology and loves to get hands dirty