Bài đăng

Đang hiển thị bài đăng từ tháng 5 3, 2014

Part 4: Adding an Admin View theo http://www.asp.net/

Hình ảnh
Add an Admin View Now we’ll turn to the client side, and add a page that can consume data from the Admin controller. The page will allow users to create, edit, or delete products, by sending AJAX requests to the controller. In Solution Explorer, expand the Controllers folder and open the file named HomeController.cs. This file contains an MVC controller. Add a method named  Admin : public ActionResult Admin () { string apiUri = Url . HttpRouteUrl ( "DefaultApi" , new { controller = "admin" , }); ViewBag . ApiUrl = new Uri ( Request . Url , apiUri ). AbsoluteUri . ToString (); return View (); } The  HttpRouteUrl  method creates the URI to the web API, and we store this in the view bag for later. Next, position the text cursor within the  Admin  action method, then right-click and select  Add View . This will bring up the  Add View  dialog. In the  Add View  dialog, name the view "Admin". Select the check box lab