using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace myblog
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明，
    // 请访问 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

           
            routes.MapRoute(
               "Default", // 路由名称
               "{controller}/{action}/{page}", // 带有参数的 URL
               new { controller = "Blog", action = "Index",page =1} // 参数默认值
           );
            routes.MapRoute(
             "Default2", // 路由名称
             "{controller}/{action}/{id}", // 带有参数的 URL
             new { controller = "Blog", action = "Index", id = 1 } // 参数默认值
         );
            //routes.MapRoute(
            //    "Month",
            //    "{controller}/{action}/{year}-{month}-{page}",
            //    new { controller = "Blog", action = " BlogByMonth", year =System.DateTime.Now.Year, month = System.DateTime.Now.Month, page = 1 });
             
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }

        protected void Application_Error()
        {
            MVCBlogo.NET.BO.Log log = new MVCBlogo.NET.BO.Log();
            log.date = System.DateTime.Now;
            log.@event = Server.GetLastError().ToString();
            MVCBlogo.NET.BLL.LogManager.Save(log);
        }
    }
}