此代码用于传递List<String>withRedirectToAction方法:
public List<String> ListOfBrandNames(string id)
{
var result = db.Items.Where(x => x.Category.Name.Equals(id)).Select(x => x.BrandID).ToList();
var ListOfBrands = db.Brands.Where(t => result.Contains(t.BrandID)).ToList();
List<String> BrandNames = ListOfBrands.Select(f => f.Name.ToString()).ToList();
return RedirectToAction("BrandsOfACategory", new { brands = BrandNames });
}
RedirectToAction方法抛出此错误:
无法将类型“System.Web.Mvc.RedirectToRootResult”隐式转换为“System.Collection.Generic.List”
ITMISS
天涯尽头无女友
相关分类