据我所知,ASP.Net核心在调用相关的控制器操作方法之前执行模型状态验证。这意味着在验证之前,操作方法中的代码没有机会向模型中添加数据。
让视图模型在验证之前访问额外的、非用户提交的数据的ASP.Net核心方式是什么?
示例
我正在尝试做的事情(不起作用)。
视图模型的Validate方法要求数据采用ValidOptions格式。但是,由于验证发生在控制器可以设置此属性之前,因此验证会导致视图模型引发ArgumentNullException。
// From the Controller
[HttpPost]
[ValidateAntiForgeryToken]
public async
我正在为这里的数据绑定语法而苦苦挣扎。例如,我有一个像这样的数据结构-
public class Course{
public string CourseName {get;set;}
public string CourseCode {get;set;}
public List<Instructor> InstructorsTeaching{get;set;}
}
public class Instructor{
public string InstructorName{get;set;}
public string InstructorCode{get;set;}
我想在数据字段的数据绑定字段上调用一个方法。例如:
<asp:BoundField DataField="TitlePLang" HeaderText="Batch Title" /> This is simple bound field but I want to do something like this.
<asp:BoundField DataField='<%# Eval(getCultureSpecificTitle("TitlePLang","TitleSLang",true)
在尝试配置web.config相当长的时间之后,我终于做了这件事,只为了得到以下错误:
An exception of type 'System.InvalidOperationException' occurred in System.Web.dll but was not handled in user code
Additional information: Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.
我正在尝试连接到asp