问题很简单:
假设你有一个名为Person的模型
public class Person
{
public int PersonID {get; set;}
public string Name {get; set;}
[AllowHtml] // Allow html in Intro property
public string Intro {get; set;}
[ScaffoldColumn(false)]
public string ComplicatedValue {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
在控制器的"创建"操作中
[HttpPost]
public ActionResult Create(Person o, FormCollection collection)
{
// whatever code here;
}
Run Code Online (Sandbox Code Playgroud)
如果你运行它,
我找到了这个问题的原因.
如果将功能更改为
public ActionResult Create(Person o) // Get rid of the *FormCollection collection*
{
// whatever code here;
}
Run Code Online (Sandbox Code Playgroud)
这将消除"潜在的危险"错误.
但我的问题是,对于我的应用程序,我必须在Create Action方法中使用辅助参数FormCollection集合,因为我需要使用一些其他控件值和服务器变量来为ComplicatedValue属性分配计算值.
如果ASP.NET …