我的應用程序是MVC核心C#中,我從一個方法兩個項目,對象和字符串返回一個通用存儲庫:.NET核心System.ValueTuple
public object PostWebApi(TObject model, string url, string dir)
{...
return (model, msg);}
在控制器我用
var data = _studentService.PostWebApi(WebApiDirectory());
return View(data)
傳遞模型到視圖,我得到錯誤
The model item passed into the ViewDataDictionary is of type 'System.ValueTuple
在調試時,返回的對象有兩個項目,模型和字符串。 無法弄清楚如何將模型item1傳遞給視圖。
你的價值觀,你可以顯示您的視圖的代碼?它看起來像你的看法是期待不同的類型 – Jonesopolis
@model WebUI.Models.Student。該方法返回我想用於ViewBag的模型和字符串。挑戰是如何分割item1和item2。 – hncl
@GiladGreen你需要安裝c#7的新版本。 Install-Package System.ValueTuple -Version 4.4.0。它的工作,我的應用程序是核心2.0。 – hncl