繁体   English   中英

ASP.NET MVC中的可选HttpPostedFileBase

[英]Optional HttpPostedFileBase in ASP.NET MVC

我有一个用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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM