تفاوت ViewData و ViewBag و TempData و Session در MVC
نویسنده: دادگر
تاریخ: ۱۳۹۳/۰۳/۲۳ ۱۹:۱۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
میتونید محل ذخیره سشن رو بجای حافظه، یک بانک اطلاعاتی SQL Server تعیین کنید: http://support.microsoft.com/kb/317604
یا اخیرا بجای SQL Server از بانکهای اطلاعاتی NoSQL از نوع key/value store هم برای اینکار استفاده میکنند: ASP.NET Session State Provider for Redis
مطلب خوب و جالبی بود، کاش تصویر موجود در مقاله منبع رو توی مقاله تون میاوردین، به نظرم خیلی تصویر گویا و جالبی هست
TempData["PaymentMethodsWithshippingMethods"]= await _paymentMethodService.FindAllWithShippingMethodsAsync();
var paymentMethodsWithshippingMethods = TempData
.Where(x => x.Key.Contains("PaymentMethodsWithshippingMethods"))
.Select(x => new { value = (PaymentMethodViewModel)x.Value })
.Select(x => new PaymentMethodViewModel
{
PaymentMethodId = x.value.PaymentMethodId,
Type = x.value.Type,
ShippingMethods = x.value.ShippingMethods.Select(y =>
new ShippingMethodViewModel
{
ShippingMethodId = y.ShippingMethodId,
DiscountPrice = y.DiscountPrice,
ProductPrice = y.ProductPrice,
Tax = y.Tax,
Type = y.Type,
Cost = y.Cost,
}).ToList()
}).ToList(); Unable to cast object of type 'System.Collections.Generic.List`1[MeMarketShop.ViewModel.PaymentMethod.PaymentMethodViewModel]' to type 'MeMarketShop.ViewModel.PaymentMethod.PaymentMethodViewModel'.
viewModel.PaymentMethods = (List<PaymentMethodViewModel>)TempData["PaymentMethodsWithshippingMethods"];