PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/ThinkEmailFomatter/Global.asax.cs

https://bitbucket.org/nicdao/frg-think-emailformatter
C# | 63 lines | 47 code | 12 blank | 4 comment | 0 complexity | b03482443872424d36996ba3bd772e5e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Web.Routing;
  7. using System.Data.Entity;
  8. using Autofac;
  9. using Autofac.Integration.Mvc;
  10. using System.Reflection;
  11. using ThinkEmailFormatter.IoCModules;
  12. namespace ThinkEmailFormatter
  13. {
  14. // Note: For instructions on enabling IIS6 or IIS7 classic mode,
  15. // visit http://go.microsoft.com/?LinkId=9394801
  16. public class MvcApplication : System.Web.HttpApplication
  17. {
  18. public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  19. {
  20. filters.Add(new HandleErrorAttribute());
  21. }
  22. public static void RegisterRoutes(RouteCollection routes)
  23. {
  24. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  25. routes.MapRoute(
  26. "Main", // Route name
  27. "afr/template/{templateName}", // URL with parameters
  28. new { controller = "Template", action = "Format", templateName = UrlParameter.Optional } // Parameter defaults
  29. );
  30. routes.MapRoute(
  31. "Default", // Route name
  32. "{controller}/{action}/{id}", // URL with parameters
  33. new { controller = "Template", action = "Index", id = UrlParameter.Optional } // Parameter defaults
  34. );
  35. }
  36. protected void Application_Start()
  37. {
  38. var builder = new ContainerBuilder();
  39. builder.RegisterControllers(Assembly.GetExecutingAssembly());
  40. // Register your dependencies here, before calling builder.Build()
  41. builder.RegisterModule(new ThinkModule());
  42. builder.RegisterModule(new ContextModule());
  43. IContainer container = builder.Build();
  44. DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
  45. //Database.SetInitializer(new DropCreateDatabaseAlways<ThinkEmailFormatterDB>());
  46. AreaRegistration.RegisterAllAreas();
  47. RegisterGlobalFilters(GlobalFilters.Filters);
  48. RegisterRoutes(RouteTable.Routes);
  49. }
  50. }
  51. }