我正在尝试执行编辑页面,以便管理员修改数据库中的数据。不幸的是,我遇到了一个错误。“参数字典包含参数的空条目” - 如何解决?
下面的代码:
public ViewResult Edit(int productId) {
// Do something here
}
,但我收到此错误:
"The parameters dictionary contains a null entry for parameter 'productId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ViewResult Edit(Int32)' in 'WebUI.Controllers.AdminController'. To make a parameter optional its type should be either a reference type or a Nullable type.
Parameter name: parameters"
我改变了我的路线Global.asax.cs
这样的:
routes.MapRoute(
"Admin",
"Admin/{action}/{ productId}",
new { controller = "Admin", action = "Edit", productId= "" }
);
但还是我得到错误 。