【发布时间】:2017-05-18 06:54:09
【问题描述】:
我正在尝试实现一个编辑页面,以便管理员修改数据库中的数据。不幸的是,我遇到了一个错误。
以下代码:
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= "" }
);
但我仍然收到错误。
【问题讨论】:
标签: c# asp.net asp.net-mvc