mvc 伪静态<一> 代码详细

控制器 ( 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 name
string.Format(url, "sx/cnblogs/test/{cityID}/{productType}/{currentPageIndex}/{sortType}"),//URL with parameters
new { controller = "Product", action = "ProductList", cityID = "155", productType = "13", currentPageIndex = 1, sortType = 0 }

);
时间: 2024-08-24 09:45:31

mvc 伪静态<一> 代码详细的相关文章

mvc伪静态&lt;三&gt; IIS配置

上一篇已经已经讲述了mvc伪静态的代码实现. 下面以IIS 7.5为例演示一下IIS如何配置才能在服务器显示.html的伪静态 一.进入IIS,选择处理程序映射 二添加脚本映射 三根据你的处理程序的版本(你部署的网站的应用程序池的版本). 然后查找asp.net处理程序的路径 比如 可执行文件:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

MVC3/4伪静态 jexus mvc伪静态

第一步修改RouteConfig.cs文件 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "ActionHtml", // action伪静态 "{controller}/{action}.jsp/{id}",// 带有参数的 URL new

压缩跟踪(CT)代码详细学习_模块1(样本的采集和扩充)

本章主要详解的是compressive tracking框架中的第一部分:样本的采集和扩充部分. 在开始代码学习的前面,你需要知道的理论知识参见论文:Real-time Compressive Tracking.理论理解可以参见我的博客:http://blog.csdn.net/ikerpeng/article/details/19826409 . 这个模块中你需要知道一个基本的概念:代码里面几个变量指的是什么.上一张图: 也许你现在还不知道他们是什么,直接贴代码了.相信有我的注释你一定会懂的.

ASP.NET MVC 伪静态的实现

public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute("Category", "list/{filterAttr}-{cateId}-{brandId}-{sortColumn}-{page}.html&qu

压缩跟踪(CT)代码详细学习_模块2(特征的提取和计算)

0.下载安装Opencv,当前版本为249. 1.下载Python,当前OPencv版本为249,不过其支持的最新版本的Python为2.7,所以可以下载276版本. 2.下载numpy,开始我使用了1.6,没有通过,错误如图.下载了最新的1.8.1版本. 3.将Opencv安装目录下opencv\build\python\2.7\x86中的cv2.pyd复制到python安装目录Lib\site-packages下. 4.找到opencv源文件内的draw.py运行. 压缩跟踪(CT)代码详细

压缩跟踪(CT)代码详细学习0

接下来我想比对CT那篇文章(http://blog.csdn.net/ikerpeng/article/details/19826409)的代码,逐行的解释,逐行的敲代码并最终实现.希望通过这个过程提高我的C编程的能力,以及对于目标跟踪的框架更进一步熟悉.希望对于后面的研究打下好的基础. 当然我会从各个模块的角度来书写,这样思路更加的清晰一点.大致的思路如下: 1中主要包括两个函数,扩充正负样本的函数,原理参见http://blog.csdn.net/ikerpeng/article/detai

Asp.net mvc 5 CRUD代码自动生成工具- vs.net 2013 Saffolding功能扩展

Asp.net mvc 5 CRUD代码自动生成工具 -Visual Studio.net2013 Saffolding功能扩展 上次做过一个<Asp.net webform scaffolding结合Generic Unit of Work & (Extensible) Repositories Framework代码生成向导> 是生存Web Form的. 这次看到网上有生成MVC Saffolding扩展原作者的代码 https://github.com/robinli/MVC5-

MVC 伪静态路由

定义URL @Html.ActionLink("html", "Get_Page", new { id=1}) 这URL是调用本控制器下面的的Get_Page方法,传参id 定义路由 routes.MapRoute(                name:"UrlHtml",                url:"{controller}/{action}/{id}.html"                ); 注册路由

ABP+Zero+Metronic+Redis的完美结合快速启动模板(超级代码详细注释版本)

微信扫一扫并支付成功,联系QQ:770628656获取所有源码(超级代码详细注释版本) 原文地址:https://www.cnblogs.com/abpbasic/p/8124792.html