C#MVC框架中的model验证,在其他架构中使用(Winform或控制台)

上传者: 33376883 | 上传时间: 2021-01-29 17:11:35 | 文件大小: 192KB | 文件类型: RAR
在.NET MVC中,当页面提交model到Action的时候,自动填充ModelState。使用ModelState.IsValid进行方便快捷的数据验证,其验证也是调用命名空间System.ComponentModel.DataAnnotations和System.ComponentModel中的各种方法进行验证。 但是,使用非MVC架构时,就需要写很多if判断或者正则表达式,当有多个字段需要验证的时候就需要写很多if判断,即繁琐,又不美观。这里记录一个方法,使用System.ComponentModel.DataAnnotations和System.ComponentModel来实现自己

文件下载

资源详情

[{"title":"( 55 个子文件 192KB ) C#MVC框架中的model验证,在其他架构中使用(Winform或控制台)","children":[{"title":"MvcModelValidateDemo","children":[{"title":"ConsoleApp1","children":[{"title":"bin","children":[{"title":"Debug","children":[{"title":"ConsoleApp1.exe <span style='color:#111;'> 5.00KB </span>","children":null,"spread":false},{"title":"Model.dll <span style='color:#111;'> 5.00KB </span>","children":null,"spread":false},{"title":"Model.pdb <span style='color:#111;'> 15.50KB </span>","children":null,"spread":false},{"title":"Validatetion.dll <span style='color:#111;'> 6.50KB </span>","children":null,"spread":false},{"title":"ConsoleApp1.pdb <span style='color:#111;'> 15.50KB </span>","children":null,"spread":false},{"title":"Validatetion.pdb <span style='color:#111;'> 17.50KB </span>","children":null,"spread":false},{"title":"ConsoleApp1.exe.config <span style='color:#111;'> 189B </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"obj","children":[{"title":"Debug","children":[{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"ConsoleApp1.exe <span style='color:#111;'> 5.00KB </span>","children":null,"spread":false},{"title":"ConsoleApp1.csprojAssemblyReference.cache <span style='color:#111;'> 35.71KB </span>","children":null,"spread":false},{"title":"ConsoleApp1.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 6.75KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"ConsoleApp1.pdb <span style='color:#111;'> 15.50KB </span>","children":null,"spread":false},{"title":"ConsoleApp1.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"ConsoleApp1.csproj.FileListAbsolute.txt <span style='color:#111;'> 954B </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"Properties","children":[{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.29KB </span>","children":null,"spread":false}],"spread":true},{"title":"Program.cs <span style='color:#111;'> 856B </span>","children":null,"spread":false},{"title":"App.config <span style='color:#111;'> 189B </span>","children":null,"spread":false},{"title":"ConsoleApp1.csproj <span style='color:#111;'> 2.70KB </span>","children":null,"spread":false}],"spread":true},{"title":".vs","children":[{"title":"MvcModelValidateDemo","children":[{"title":"v15","children":[{"title":".suo <span style='color:#111;'> 23.50KB </span>","children":null,"spread":false},{"title":"Server","children":[{"title":"sqlite3","children":[{"title":"db.lock <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"storage.ide <span style='color:#111;'> 4.00KB </span>","children":null,"spread":false},{"title":"storage.ide-shm <span style='color:#111;'> 32.00KB </span>","children":null,"spread":false},{"title":"storage.ide-wal <span style='color:#111;'> 2.95MB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":"Model","children":[{"title":"bin","children":[{"title":"Debug","children":[{"title":"Model.dll <span style='color:#111;'> 5.00KB </span>","children":null,"spread":false},{"title":"Model.pdb <span style='color:#111;'> 15.50KB </span>","children":null,"spread":false}],"spread":true},{"title":"Release","children":null,"spread":false}],"spread":true},{"title":"obj","children":[{"title":"Debug","children":[{"title":"Model.csproj.FileListAbsolute.txt <span style='color:#111;'> 425B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Model.dll <span style='color:#111;'> 5.00KB </span>","children":null,"spread":false},{"title":"Model.pdb <span style='color:#111;'> 15.50KB </span>","children":null,"spread":false},{"title":"Model.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 6.66KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Model.csprojAssemblyReference.cache <span style='color:#111;'> 2.04KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"Properties","children":[{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.27KB </span>","children":null,"spread":false}],"spread":true},{"title":"UserInfo.cs <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false},{"title":"Model.csproj <span style='color:#111;'> 2.21KB </span>","children":null,"spread":false}],"spread":true},{"title":"Validatetion","children":[{"title":"bin","children":[{"title":"Debug","children":[{"title":"Validatetion.dll <span style='color:#111;'> 6.50KB </span>","children":null,"spread":false},{"title":"Validatetion.pdb <span style='color:#111;'> 17.50KB </span>","children":null,"spread":false}],"spread":true},{"title":"Release","children":null,"spread":false}],"spread":true},{"title":"obj","children":[{"title":"Debug","children":[{"title":"Validatetion.csproj.FileListAbsolute.txt <span style='color:#111;'> 509B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Validatetion.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 6.68KB </span>","children":null,"spread":false},{"title":"Validatetion.csprojAssemblyReference.cache <span style='color:#111;'> 11.01KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Validatetion.dll <span style='color:#111;'> 6.50KB </span>","children":null,"spread":false},{"title":"Validatetion.pdb <span style='color:#111;'> 17.50KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"Properties","children":[{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.28KB </span>","children":null,"spread":false}],"spread":true},{"title":"Validatetion.csproj <span style='color:#111;'> 2.23KB </span>","children":null,"spread":false},{"title":"ValidatetionHelper.cs <span style='color:#111;'> 3.42KB </span>","children":null,"spread":false}],"spread":true},{"title":"MvcModelValidateDemo.sln <span style='color:#111;'> 2.04KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明