ASP.NET MVC中的可选HttpPostedFileBase

里卡多·波罗·贾拉米洛(Ricardo Polo Jaramillo)

我有一个用MVC编写的ASP.NET Web API。我有一些可选参数的后期处理。

public Guid PostExecution(string Action, List<Guid> ComputersIDs, int Port = 0, string Command = null, string Password = null)

它完美地工作。现在,我需要执行此操作来接收通过post方法发送的可选文件。

所以:

public Guid PostExecution(string Action, List<Guid> ComputersIDs, int Port = 0, string Command = null, string Password = null, HttpPostedFileBase file = null)

有趣的是,当我添加参数时HttpPostedFileBase,服务器停止响应该操作的请求,并仅显示Error 500 Internal Server error。它不会引发任何异常。带有断点的代码不会输入到中PostExecution

为什么会这样?

如何调试此错误?

是否可以有一个可选的HttpPostedFileBase

米拉德·侯赛因·帕纳西(Milad Hosseinpanahi)

所有发布的文件都是可选的!

您可以通过来获取它们Request.Files,而不必将它们包含在methods参数中

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章