【发布时间】:2014-05-26 04:24:01
【问题描述】:
我有一个带有 3 个参数的 ActionResult,但是在 y 从另一个 ActionResult 重定向的那一刻,由于 3 个参数为空而抛出错误。
pubblic ActionResult Comentar()
{
return Redirect("GeneralTop");
}
[HttpGet]
public ActionResult GeneralTop(string name, int opcion, int id)
{
My code
}
当我从 Comentar 重定向时,视图不起作用。请帮忙? (引擎aspx)
【问题讨论】:
-
您可以通过使用可空类型(例如
int? opcion)来使参数可选 -
但如果我这样做,在使用 opcion 的变量中抛出下一个错误,不能转换 int?进入int
标签: c# asp.net parameters controller optional