小编Vit*_*ugo的帖子

传递到 ViewDataDictionary 的模型项的类型为“...”,但此 ViewDataDictionary 实例需要类型为“...”的模型项

我在做什么?
我正在尝试在一个视图中使用两个模态。

有什么问题?
运行时出现这个错误:

An unhandled exception occurred while processing the request.
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'ProgramaEstagio.Models.Person', but this ViewDataDictionary instance requires a model item of type 'ProgramaEstagio.Models.RegisterViewModel'.

Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible(object value)
Run Code Online (Sandbox Code Playgroud)

“PersonController.cs”的一部分:

An unhandled exception occurred while processing the request.
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'ProgramaEstagio.Models.Person', but this ViewDataDictionary instance requires a model item of type 'ProgramaEstagio.Models.RegisterViewModel'.

Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible(object value)
Run Code Online (Sandbox Code Playgroud)

注册ViewModel.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc razor asp.net-core

4
推荐指数
1
解决办法
9537
查看次数

标签 统计

asp.net ×1

asp.net-core ×1

asp.net-mvc ×1

c# ×1

razor ×1