1.2.1.Action

1.Action Result

  • reference from udemy.com [the complete aspnet mvc 5 course

2.Parameters source

  • 1.以下寫法都會導到MovieController.Edit(int id):

    • 1.In the url

      • movie/edit/1

    • 2.In the query string

      • movie/edit?id=1

        public ActionResult Edit(int id)
        {
            return Content("id = " + id);
        }
  • 2.Pass option parameters

    • movie/index?pageindex=100

    • movie/index?sortBy=releaseDate

      public ActionResult Index(int? pageIndex, string sortBy)
        {
            if(!pageIndex.HasValue)
            {
                pageIndex = 1;
            }
      
            if(String.IsNullOrWhiteSpace(sortBy))
            {
                sortBy = "Name";
            }
      
            return Content(String.Format("pageIndex={0}&sortBy={1}", pageIndex, sortBy));
        }

Last updated

Was this helpful?