Tag: actionmethod

我应该如何从控制器动作c#asp.net-mvc-2返回一个图像?

我正在从像下面的byte[]构建图像。 public FileContentResult GetEmployeeImage(int empId) { MemoryStream ms = new MemoryStream(byteArray); Image returnImage = Image.FromStream(ms); return returnImage;//How should i return this image to be consumed by javascript. } 我想通过控制器操作方法将此图像返回到浏览器,因此它可以被我的javascript代码使用并显示在浏览器中。 我该怎么做?

ASP .NET MVC NonAction含义

任何人都可以告诉我为什么要使用NonAction? 我的意思是说我有一个包含多个提交值的表单:Update,Delete或Insert。 由于所有提交按钮具有相同的共同forms,因此我在控制器内切换提交值并采取相应措施。 像这样: public ActionResult asd(string submitButton){ switch(submitButton){ case “Insert”: return Insert(); // bla bla bla } } [NonAction] public ActionResult Insert(){ // some code inside here return View(); } 再一次,我为什么要使用NonAction而不是这样的东西: public void Insert(){ // some code inside here }