c0shea / AdminLTE-Template

A C# MVC Template for Visual Studio using the popular AdminLTE Bootstrap Template.
MIT License
67 stars 31 forks source link

ASP.NET MVC CORE - Controller to View bug #28

Closed airmikec closed 2 years ago

airmikec commented 2 years ago

Controller Browser Error

Hey.. Thank you for building this Template. It's pretty amazing and I like it a lot. You made it very easy to work with. However, I am running across a problem that I am hoping you can help with.

I am using Visual Studio 2019. ASP.NET MVC Core & your template. Machine HP ZBook, 16GB Ram, 500+ GB of free hard drive space. Just the details here. I am sure it has nothing to do with my hardware.

As you can tell from the "Controller" image I am passing a class (object) to the View, theoretically the employee model would have data in it, so that it can be shown on the screen. However, every time I pass in an object to the View for rendering the data, I get the error as shown in the "Browser Error" image. I have looked at nearly everything.

This same error happens on any Controller when I am passing back the model I have tried 3 different views from 3 different controllers. If I remove the model the page loads, but I don't have any of the model data. Sometimes ASP.NET MVC Core has problems with object variable names. I commented out all of the variable names except for PK (Primary Key) because I know that variable name doesn't conflict with ASP.NET MVC CORE.

I keep stipulating CORE because some of the problems I have come across with CORE I have never had in ASP.NET MVC using .NET FRAMEWORK. But .NET FRAMEWORK is now dead, and I switched to CORE.

I will stipulate that this is my first CORE website, so I might be doing something wrong, but when I did research online it shows that I am still doing it the right way. Also I will note that, yes, I know how to read and the error says I am passing in my company_employeesDTO model and it's expecting blah..blah.._Sidebar. That is your sidebar.cshtml file and I can't pass that in. Moreover it shouldn't expect me to pass that in. Also I have made sure 10 times that I am passing the correct model from the Controller to the VIew. They both have the same namespace and object name, so that shouldn't be the problem either.

I was hoping you could help me figure out the problem. Thank you for your time and I hope you have a great day.

c0shea commented 2 years ago

Hi @airmikec! I haven't updated the template to work with .NET Core/.NET 5/.NET 6. Looking at the stacktrace in your screenshot, it seems like you've modified some part of your views (either the main layout, sidebar, etc.) to expect a model and it's not being passed in. Not sure that I can help much more from here as this isn't a template issue.