Tôi gặp sự cố lạ với chế độ xem của tôi trong dự án MVC 3. Tôi có chế độ xem chuẩn để chỉnh sửa dữ liệu (được tạo bằng mẫu). Khi tôi gửi biểu mẫu, tôi thay đổi thuộc tính Name
, nhưng sau khi tôi quay lại trình duyệt từ trình điều khiển, tôi vẫn thấy giá trị lorem
. Tại sao ?MVC 3 Chế độ xem không được làm mới sau khi gửi mẫu
@using (Html.BeginForm())
{
@Html.EditorFor(model => model.Name)
<input type="submit" value="Save" />
}
public ViewResult EditUserData(int id)
{
[...]
UserData model = new UserData();
model.Name = "lorem";
return View("~/Views/UserDetails.cshtml", model);
}
[HttpPost]
public ViewResult EditUserData(UserData model)
{
model.Name = "ipsum";
return View("~/Views/UserDetails.cshtml", model);
}
public class ControlUserData
{
[...]
[Required]
[Display(ResourceType = typeof(Resources), Name = "UserNameFirst")]
public string Name { get; set; }
}
đã hành động bài bị trúng? visual breakpoint studio ?? – Shyju
@Shyju Có, trình gỡ lỗi gọi hành động của HttpPost sau khi tôi nhấn nút gửi – Tony
Tại sao 'Xem (" ~/Views/UserDetails.cshtml ", Model)' thay vì đặt nó trong thư mục được chia sẻ và thực hiện 'Xem (" UserDetails ", Model)"? –