【发布时间】:2014-01-14 07:16:08
【问题描述】:
我有一个控制器动作,它采用自定义类型的参数:
public class SomeController : Controller
{
public ActionResult Index(CustomType someValue)
{
throw new NotImplementedException();
}
}
ASP.NET MVC 不知道自定义类型,它不是“复杂”类型;它需要自定义创建逻辑:
public class CustomType
{
public CustomType(string data){}
}
在这个例子中,我希望能够告诉 ASP.NET MVC,每当它需要绑定到 CustomType 时,它应该使用以下过程:
(string someRequestValue) => new CustomType(someRequestValue)
我快速浏览了一下这里和谷歌,但我没有找到任何涵盖这个简单场景的东西。
【问题讨论】:
标签: .net asp.net-mvc model-binding