Special methods and tricks in ASP.NET MVC? [closed]
Please tell me your favorite trick and tips to me. I want to collect so much knowledge as I can. And I think it's the best way to hear it from experts and amateur developers.
1. HTML FORM Tag + Attribute "multipart/form-data" and HttpPostedFileBase
I cloud tell you something about htm开发者_如何学Gol form tag. If you use form tag in MasterPage of your MVC project. And you need in one only View one extra attribute for Image Uload like: "multipart/form-data". Be carefull, look at your Code-Source, because you could have 2 Form tags and your parameter of type HttpPostedFileBase can always be null. I solved it so: Activated "multipart/form-data" in form just if this View will called. I did it in codebehind and I know it is not nice solution.
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Form.Enctype = "multipart/form-data";
}
Using Html.Serialize helper method to persist view models between pages and of course MVCContrib.
精彩评论