mono / mono

Mono open source ECMA CLI, C# and .NET implementation.
https://www.mono-project.com
Other
11.13k stars 3.82k forks source link

Render Partial View (ASP.NET MVC on Visual Studio for Mac) #9192

Open ghost opened 6 years ago

ghost commented 6 years ago

Please, take a look on it...

https://stackoverflow.com/questions/50840381/partial-view-render-error-when-running-in-mono-on-mac

marek-safar commented 6 years ago

Please provide steps how to reproduce the issue

ghost commented 6 years ago

Hello Marek,

What's going on is, I have a project ASP.NET MVC that when I run on Windows works perfectly,

But when I run on Mac (Visual Studio for Mac) and go to SPECIFIC PAGES (Pages where I use partial views FROM ANOTHER FOLDER) I got this error.

It's kind of the MONO doesn't recognize partial views FORM ANOTHER FOLDER.

Ex.: I have a View PERSON (~/Views/Person/Index.cshtml) where inside of this view I have one partial view for CONTACTS (~/Views/Contact/_listContacts.cshtml).

If I open the view PERSON on WINDOWS, everything runs well.

If I open the view PERSON on MAC (Visual Studio for Mac/Mono) I got this error.

Is it helps? Let me know if you need more details, maybe I can record a video to show to you.

Thanks.

Thomas-Lettieri-IPS commented 5 years ago

Update: I figured out what causes my issue below:

Having an await in a controller method causes the issue, I left the function as async and commented out everything but the return and it worked, I then only included the await call (not even adding it to a variable) and it failed.

However using a breakpoint I see that the async await is working as expected (my code is calling an api and I am getting expected results in the variables), it's just the return becomes a 500 because it can't find the view. I have also concluded that this has nothing to do with the partial views, they were just the only views using async await.


I have also experienced this problem:

Env: Asp.NET 4.6.2 MVC Razor engine Mac Version 10.14.5 Windows 10 Windows IDE: Visual Studio Community 2019 Mac IDE: Visual Studio for Mac Community v 8.2.2 (Build 21)

I started a project on windows but wanted to continue to work on it on Mac so I simply cloned it on my mac side and ran it. It built and the default page came up without any problems. However once I went to a view that used partial views I was getting server errors for the partial view. Although it could not find the cshtml file it was able to execute the controller logic for that endpoint.

So my final test was to open the partial view instead of the parent view, I get a 500 and it tells me all the paths it looked for the file and couldn't find it I then stopped the project and added another partial view and tried to load it directly (I tried it again as an async function after a normal partial view), it worked both ways

So /Home/MyExistingPartialView.cshtml resulted in a 500 /Home/MyNewPartialView.cshtml returned the expected payload

I checked the versioned files to see what might be different but I don't see any differences, it added the "Content" tag to the project with the expected file in the same format as the broken files