Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 2 của 2
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    File Global.asax có tác dụng gì trong ASP.NET MVC?

    Khi tạo một Project ASP.NET MVC ta có được file Global.asax. Mình biết sơ qua thì nó làm nhiệm vụ xử lý URL để đưa đến một class Controller tương ứng. Không biết hiểu như thế có đúng ko? Và đọc ko hiểu lắm [IMG]images/smilies/offline.gif[/IMG]
    Đoạn code trong file đó mặc định như sau:

    Mã:
    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using System.Web.Routing; namespace MyMVCApplication{    // Note: For instructions on enabling IIS6 or IIS7 classic mode,     // visit 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", // Route name                "{controller}/{action}/{id}", // URL with parameters                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults            );         }         protected void Application_Start()        {            AreaRegistration.RegisterAllAreas();             RegisterRoutes(RouteTable.Routes);        }    }}
    Bạn nào đã từng thao tác hoặc hiểu file này thì giải thích giúp mình bằng cách comment vào các dòng code. Mình cảm ơn!

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •