私はこのチュートリアルを行ってきましたが、とても良さそうです。それで、私はそれを調べて、サンプルファイルをダウンロードしました。
私はそれをいじっていて、それを使用する方法を理解しており、独自の検証も追加することができました。
そこで、現在取り組んでいるプロジェクトに追加することにしました。コンパイルして実行することはできましたが、フォームを試してみると、検証(クライアント側とサーバー側の両方)は発生しません。
どうしてか分かりません。だから私は別のプロジェクトを作成し、すべてのものをもう一度追加しようとしましたが、何が欠けているのかわかりません。
これは、コードをコピーして貼り付けるにはファイルが多すぎることを示す唯一の方法です。
テスト用のリモート検証部分もまだ使用していません。私が持っていたのは「必要なメール」だけです。
今すぐ編集するとエラーが発生します
System.IO.FileNotFoundException was unhandled by user code
Message="Could not load file or assembly 'System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
Source="Online.com"
FileName="System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
FusionLog="=== Pre-bind state information ===\r\nLOG: User = CHOBO2\\chobo\r\nLOG: DisplayName = System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\n (Fully-specified)\r\nLOG: Appbase = file:///I:/OnlineV2/trunk/Current Site/\r\nLOG: Initial PrivatePath = I:\\OnlineV2\\trunk\\Current Site\\bin\r\nCalling assembly : Online.com, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: I:\\OnlineV2\\trunk\\Current Site\\web.config\r\nLOG: Using machine configuration file from C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.\r\nLOG: Post-policy reference: System.ComponentModel.DataAnnotations, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nLOG: The same bind was seen before, and was failed with hr = 0x80070002.\r\n"
StackTrace:
at Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder.GetTypeDescriptor(Object model, Type modelType)
at Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder.GetModelProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) in I:\OnlineV2\trunk\Current Site\Models\DataAnnotationsModelBinder\DataAnnotationsModelBinder.cs:line 35
at System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model)
at System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
InnerException: