我有一个用MVC编写的ASP.NET Web API。我有一些带有一些可选参数的post动作。
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
时,服务器停止响应对此操作的请求,并且只显示错误500内部服务器错误。它没有抛出任何异常。使用断点,代码不会进入PostExecution
。
为什么会这样?
我该如何调试此错误?
是否可以选择HttpPostedFileBase
?
所有发布的文件都是可选的
你可以通过Request.Files
获得它们,而且你不需要在methods参数中使用它们