我正在編寫搜索頁的代碼,我必須通過一些過濾器的行動,並根據那些輸入,我必須生成超鏈接,因此我使用Url.Action函數來生成鏈接。在Url.Action中使用列表<int>方法
下面是我的代碼
@Url.Action("Index","Search",new SkillKindleWeb.ViewModels.Search.SearchRawInput()
{
CategoryIds = Model.Request.CategoryIds,
SubCategoryIds = Model.Request.SubCategoryIds,
StartDate = Model.Request.StartDate,
EndDate = Model.Request.EndDate,
StartPrice = Model.Request.StartPrice,
LocationGroupIds = Model.Request.LocationGroupIds,
LocationIds = Model.Request.LocationIds,
EndPrice = Model.Request.EndPrice,
City = Model.Request.City,
PageNo = 1,
SearchQuery = Model.Request.SearchQuery,
Segment1 = Model.Request.Segment1,
Segment2 = Model.Request.Segment2,
TargetAge = Model.Request.TargetAge
})
並且它產生像URL這
http://someDomain.com/ncr/classes?CategoryIds=System.Collections.Generic.List%601%5BSystem.Int32%5D &的StartDate = 03%2F30 %2F2013%2000%3A00 3A00%& StartPrice = 0 & EndPrice = 140000 &您做生意= 2
我的預期地址是
http://SomeDomain.com/ncr/classes?CategoryIds=9&StartDate=3/30/2013&StartPrice=0&EndPrice=140000
什麼是'SearchRawInput'?看起來你的'List'被轉換爲'string',而'StartDate'沒有按照你的意願格式化。 –
看起來你的CategoryIDs不是一個單一的值,而是一個列表。那是你要的嗎。? – serene
是的,我想它給我一個字符串像CategoryId = 1和CategoryId = 2 – rajansoft1