質問

Currently I'm working with image uploading using MVC3. When I did some searches for sample code I found out several approaches. I figured out almost 3 methods. Can someone explain which one is better over the other or all of them are the same? An explanation when it comes to performance or anything is welcome.

Method 1: As parameter

public ActionResult UploadImage(HttpPostedFileBase img)
        {

            return View();
        }

Method 2: From Request.Files

HttpPostedFileBase imgFile= Request.Files["img"];

Method 3: From Image Helper

var imgFile= WebImage.GetImageFromRequest();
役に立ちましたか?

解決

The first is the best approach. The reason for that is because this will make the action easier to unit test and it doesn't rely on magic strings.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top