开发者

What property type for uploaded files, when designing a model class in ASP.NET MVC 3?

开发者 https://www.devze.com 2023-02-03 13:39 出处:网络
I have a form on an ASP.NET MVC site, it will upload a couple of files. I\'m trying to mimic the default project\'s \"AccountModel\" or \"LoginModel\" examples, to build DataAnnotation based server an

I have a form on an ASP.NET MVC site, it will upload a couple of files. I'm trying to mimic the default project's "AccountModel" or "LoginModel" examples, to build DataAnnotation based server and client side validation (unobtrusive jQuery plugin based client side validation, new in MVC 3.0).

For example:

public string FirstName
public string LastName
public string Email
public ?? Photo
public ?? File

Each of those properties matches the name/id of a form field on the page. When sub开发者_StackOverflowmitted, ASP.NET MVC should map those fields to the properties.

What do I set the Photo/File properties to so they are mapped by MVC and can be validated with DataAnnotations?


I believe you are looking for HttpPostedFileBase

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号