我的应用程序是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