开发者

Check model's ModelState in FileStreamResult action in ASP.NET MVC

开发者 https://www.devze.com 2022-12-30 03:25 出处:网络
I ha开发者_如何学运维ve a page that a user selects what he wants to download, the submit button posts the form to

I ha开发者_如何学运维ve a page that a user selects what he wants to download, the submit button posts the form to

public FileStreamResult GetFiles(FileSelectionModel model)
{
   //zips files into one zip
   return File();
}

However, what if the model wasn't in a valid state? How do I check it? It wouldn't let me return View() or return RedirectToAction() here

thanks


Change the return type of your action from FileStreamResult to the more generic ActionResult, then you can return View() or RedirectToAction().

HTHs,
Charles

0

精彩评论

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