id-parameter of string type doesn't have optional attribute
Imported from the CodePlex archive for reference purposes. Support for MvcCodeRouting has ended.
Commented on
Hello.
I have a controller with string parameter on action method:
public class TestController : Controller
{
public ActionResult GetSmth(string id)
{
if (String.IsNullOrEmpty(id))
return Content("Empty");
else
return Content("NonEmpty");
}
}
public class TestController : Controller
{
public ActionResult GetSmth(string id = null)
{
if (String.IsNullOrEmpty(id))
return Content("Empty");
else
return Content("NonEmpty");
}
}