mvc 偽靜態<一> 代碼詳細

來源:互聯網
上載者:User

標籤:

 

控制器 ( Controller) Product

下面功能主要根據多條件搜尋產品的列表的功能

 public ActionResult ProductList(string cityID, string productType,string currentPageIndex,string sortType)        {            SearchConditionInfo condtions = new SearchConditionInfo();            if (string.IsNullOrEmpty(cityID))            {                cityID = "17";            }            if (string.IsNullOrEmpty(productType))            {                productType = ProductType.Hotel;            }            if (string.IsNullOrEmpty(sortType))            {                sortType = SortType.Default;            }            if (string.IsNullOrEmpty(currentPageIndex))            {                currentPageIndex = "1";            }            condtions.CityID =cityID;            condtions.Topcount = "300";            condtions.ItemType = productType;            condtions.SortType = sortType;            condtions.PageSize = "30";            condtions.SortType = sortType;                            List<ProductInfo> GroupProductInfoList = APIRequsetClient.ProductList(condtions);                                PagedList<ProductInfo> ProductPageList = GroupProductInfoList.AsQueryable().ToPagedList<ProductInfo>(int.Parse(currentPageIndex), 30);            ProductPageList.TotalItemCount =GroupProductInfoList.Count;            ProductPageList.CurrentPageIndex =int.Parse(currentPageIndex);                                  return View( ProductPageList);                                }        

視圖 View

   接著我們需要有一個在視圖做一個超連結這個連結跳到產品列表頁ProductList

  @Html.RouteLink("這個是產品分類導航的某一項", "ProductListPage", new { cityID = Model.CurrentCityID, productType = ProductType.Hotel } })   

路由配置(重點)

 

string url = "{0}.html";routes.MapRoute("ProductListPage",//Route namestring.Format(url, "sx/cnblogs/test/{cityID}/{productType}/{currentPageIndex}/{sortType}"),//URL with parametersnew { controller = "Product", action = "ProductList", cityID = "155", productType = "13", currentPageIndex = 1, sortType = 0 });

 

mvc 偽靜態<一> 代碼詳細

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.