我认为这里有一个棘手的问题!
我想了解如果这个 Cart 对象是如何使用模型绑定器按值传递的,那么它如何影响会话中的实际值?
public RedirectToRouteResult AddToCart(Cart cart, int productId, string returnUrl) {
Product product = repository.Products
.FirstOrDefault(p => p.ProductID == productId);
if (product != null) {
cart.AddItem(product, 1);
}
return RedirectToAction("Index", new { returnUrl });
}
希望这能解释我的问题!
感谢您的帮助
细节
此粗体代码不会影响会话中的自定义配置文件
[AllowAnonymous]
[HttpPost]
public ActionResult Register(RegisterModel model, CustomProfile customProfile)
{
if (User.Identity.IsAuthenticated)
return RedirectToAction("Index", "Home");
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
membershipProvider.CreateUser(model, null, null, true, null,
out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
const string message = "You have successfully reigestered, and you are now logged in.";
authProvider.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
var newCustomProfile = new CustomProfile(model.UserName);
var db = new CrowdFundingDB();
**customProfile = customProfileProvider.Create(newCustomProfile);**