dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.34k stars 9.98k forks source link

用netcoreapp2.1 搭建页面遇到 InvalidOperationException 问题-Encounter InvalidOperationException problems with netcoreapp2.1 building pages #12037

Closed vsfeedback closed 5 years ago

vsfeedback commented 5 years ago

新手在学 ASP.NET Core

用 netcoreapp2.1 搭建不含model 的页面 在布局时 用 <partial name="" /> 遇到个问题 用这个时一直报

“An unhandled exception occurred while processing the request. InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'CmsAspCore.Pages.IndexModel', but this ViewDataDictionary instance requires a model item of type 'CmsAspCore.Pages.NavigationModel'. Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible(object value)”

不知道是哪里的问 求教 谢谢

Image:77713-6.png

index页面

Image:77714-2.png

_Layout页面

Image:77715-3.png

嵌套页面 Naviga

Image:77716-5.png

This issue has been moved from https://developercommunity.visualstudio.com/content/problem/600820/用netcoreapp21-搭建页面遇到-invalidoperationexception-问题.html VSTS ticketId: 915807 These are the original issue comments:

Visual Studio Feedback System on 6/10/2019, 11:12 PM (28 days ago):

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Visual Studio Feedback System on 6/11/2019, 01:48 AM (28 days ago):

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2017#faq . In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/ . We'll keep you posted on any updates to this feedback.

Jane Wu [MSFT] on 6/11/2019, 07:26 PM (28 days ago):

Translated from Bing:

Beginner is learning ASP.NET Core
Use netcoreapp2.1 to build pages that do not contain model in the <partial name=""""></partial> layout with a problem encountered when using this has been reported "An unhandled exception occurred while processing the request. Invalidoperationexception:the model item passed into the ViewDataDictionary are of type ' CmsAspCore.Pages.IndexModel ', but This ViewDataDictionary instance requires a model item of type ' CmsAspCore.Pages.NavigationModel '.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible (object value) " I don't know where to ask for advice.

Index page

_Layout page

Nested pages Naviga

These are the original issue solutions: (no solutions)

mkArtakMSFT commented 5 years ago

Hi. It looks like this is a question about how to use ASP.NET Core. While we do our best to look through all the issues filed here, to get a faster response we suggest posting your questions to StackOverflow using the asp.net-core-mvc tag.

mkArtakMSFT commented 5 years ago

The error you're receiving actually tells exactly what the problem is. It indicates and error in your page, and you should make sure you pass a proper type parameter as an input. For questions like this, StackOverflow is a great place to start with, as you'll get your questions answered quickly.

netken commented 4 years ago

我也遇到同样的问题,不知道解决没有?