發(fā)表日期:2019-04 文章編輯:小燈 瀏覽次數(shù):3121
我們通過*Route.config配置自定義文件時(shí),模板中可能會(huì)用到url中的一些節(jié)點(diǎn),下面這段配置一個(gè)自定義搜索頁(yè)面
?<route?urlConstraint="^search/([1-9]\d{0,8}/)?$"??viewPath="搜索/search.cshtml"?httpcacheSolutionId="0"?columnId="0"?title="搜索"></route>
其中([1-9]\d{0,8}/)?匹配分頁(yè)規(guī)則。
比如我們搜索頁(yè)面是:http://www.pageadmin.net/search/2/?kw=關(guān)鍵詞
那么模板中如何獲取到2這個(gè)分頁(yè)呢,自定義文件系統(tǒng)預(yù)設(shè)了一個(gè)ViewBag.CustomRouteParameter(類型為字符串?dāng)?shù)組)來保存url節(jié)點(diǎn),使用方法如下:
@{ ????????string?kw=Request.QueryString["kw"];//獲取kw參數(shù) ????????int?currentPage?=?1; ????????string[]?customRouteParameter?=?ViewBag.CustomRouteParameter; ????????if?(customRouteParameter.Length?>?1) ????????{ ????????????currentPage?=?int.Parse(customRouteParameter[1]);?//等到2,customRouteParameter[0]得到search ????????} }
日期:2019-04 瀏覽次數(shù):3145
日期:2019-04 瀏覽次數(shù):3120
日期:2019-04 瀏覽次數(shù):3029
日期:2019-04 瀏覽次數(shù):2856
日期:2019-04 瀏覽次數(shù):2946
日期:2019-04 瀏覽次數(shù):3112
日期:2019-04 瀏覽次數(shù):3048
日期:2019-04 瀏覽次數(shù):3310
日期:2019-04 瀏覽次數(shù):3361
日期:2019-04 瀏覽次數(shù):3013
日期:2019-04 瀏覽次數(shù):3390
日期:2019-04 瀏覽次數(shù):2811
日期:2019-04 瀏覽次數(shù):2955
日期:2019-04 瀏覽次數(shù):3072
日期:2019-04 瀏覽次數(shù):2923
日期:2019-04 瀏覽次數(shù):3367
日期:2019-04 瀏覽次數(shù):3267
日期:2019-04 瀏覽次數(shù):2947
日期:2019-04 瀏覽次數(shù):3171
日期:2019-04 瀏覽次數(shù):3005
日期:2019-04 瀏覽次數(shù):2776
日期:2019-04 瀏覽次數(shù):3083
日期:2019-04 瀏覽次數(shù):2972
日期:2019-04 瀏覽次數(shù):3072
日期:2019-04 瀏覽次數(shù):3023
日期:2019-04 瀏覽次數(shù):2895
日期:2019-04 瀏覽次數(shù):2749
日期:2019-04 瀏覽次數(shù):2766
日期:2019-04 瀏覽次數(shù):2828
日期:2019-04 瀏覽次數(shù):2853
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.