簡體   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