asp.net mvc default parameter attribute
Is there a way to set a default value on a parameter that was not passed, for eg:
public ActionResult Index(int? page)
{}
I'd like to have page=0
if no page was passed, so I can remove the nullable symbol. I 开发者_如何学Pythondo not want to do this in routing, just on the action itself.
Have you tried:
public ActionResult Index(int page = 0)
{}
New in C# 2010 is the ability for optional parameters:
public ActionResult Index(int page = 0)
{
}
精彩评论