C
C#

help

❔ View cannot be found.

Ppopulus2/4/2023
LoginModel.cs Pages/Account/Login.cshtml Pages/Account/Register.cshtml AccountController.cs attached. Why am I getting the following error when submitting a POST request?
An unhandled exception occurred while processing the request.
InvalidOperationException: The view 'Register' was not found. The following locations were searched:
/Views/Account/Register.cshtml
/Views/Shared/Register.cshtml
/Pages/Shared/Register.cshtml
Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable<string> originalLocations)
An unhandled exception occurred while processing the request.
InvalidOperationException: The view 'Register' was not found. The following locations were searched:
/Views/Account/Register.cshtml
/Views/Shared/Register.cshtml
/Pages/Shared/Register.cshtml
Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable<string> originalLocations)
AAngius2/4/2023
Why do you have your views in /Pages/ instead of /Views/ directory...? The exception is quite clear, it tells you what directories it searches through to find the appropriate view
Ppopulus2/4/2023
Hey, so /Pages/ was the default folder added by the scaffolding. I tried creating a /Views/ folder and moving the relevant files there but I ran into some 405 issues so I assumed /Pages/ was the correct way. I can't quite puzzle it together.
AAngius2/4/2023
If it was scaffolded code, that means what got scaffolded were some Razor Pages So either: a) Use them as they are b) Use controllers and views Trying to mix the two won't work
Ppopulus2/4/2023
So /Pages/ is not a synonym for /Views/ then? Because that's what I got when creating the project ("scaffolding"(?)). For example, there is a "/Pages/Shared/" which was searched, and even though I tried putting the "Login.cshtml" and "Register.cshtml" there it did not find them.
AAngius2/4/2023
The MVC paradigm uses /Controllers/ for controllers and /Views/ for views. The Razor Pages paradigm uses /Pages/ for... pages If you want to use MVC, it's best to place your views where views go, and controllers where controllers go If you want to use Razor Pages, place them where they go
Ppopulus2/4/2023
I did not realize these were different frameworks. But it seems like using controllers and .cshtml files with the "@page" directive works? Because that's how I got it to work partially during my work on this. You would recommend me to troubleshoot this on google by using "MVC" as part of the keyword(s) searched?
AAngius2/4/2023
I would recommend starting with placing things where they should go Or using the scaffolded Razor Pages code for auth, and not making your own implementation of it with MVC That would be the easiest
Ppopulus2/4/2023
I am on the final stretches of my C# programming course and I guess MVC was what we learned. I don't know how I got Razor pages in the mix, but I think MVC is the way to go for me. But let's suppose I did want to do the Razor Pages code way, isn't it essentially just moving the code in there? I am using Aspnet.core.Identity and entityframeworkcore for Auth and DB respectively.
AAngius2/4/2023
Identity will scaffold Razor Pages with login, registration, etc for you Once scaffolded, that's that, you don't need to touch them Or you can edit the codebehind in them if you want But trying to replace them with controllers, while still using the pages' .cshtml files is... an odd choice
Ppopulus2/4/2023
Oh really, I must have navigated around that somehow. I installed it through the NuGet package manager and no code was provided by default.
AAccord2/5/2023
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ Unsupported Media Type - Razor page```{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","st✅ JsonConvert debugging helpHello! I'm having a hard time figuring out how to solve an issue where JsonConvert.DeserializeObject❔ Make a sprite follow mouse while pivoting around character in UnityHi, I its hard to describe my issue by describing it since im not sure exactly what I'm looking for ❔ is Generic Repository a bad implementation of Repository Pattern?Surfing the internet I have found several articles that say it is an anti-pattern because it is an a❔ Problems with using Dotnet 6 on Windows to publish to an exe formatDotnet/C# newb here. Previously I've only done a small amount of development using the **.Net Framew❔ Using net7 documentation while targeting netstandard2.0This might be a bit of a dumb question, but is there anyway to make omnisharp/roslyn's tooltips use ❔ WPF app unit testingI am learning how to make unit tests. I built my app on .net core 6.0 and I created class library (o❔ where exactly should i put authorizationso i read a few posts on where to put authorization and most of the people agree on putting it in th❔ C# WPF playing background musicHello, I have WPF app for game launcher/updater. I wanted to add background music, so I added this cC# wpf mvvm Datagrid filter using LINQSo here I have a MVVM form. the Form contains a Datagrid which is connected to the Databank. I also ❔ Is it worth to create lazy dictionary in this case?I have following class: so as you see Add function add to the dictionary class TreeNode, it looks li❔ Going to use a listbox with a switch for something in the morning, need help with format for bothI would like to set two variables with a listbox using a switch and one variable with a second listb✅ What's your view on tool like Sonarqube?Should I learn from the code smells it captures?✅ Autodesk Maya HelpAnyone in here know Autodesk Maya really well? My mesh tool isn't letting my polygon primitives mesh❔ circular primesso this program is meant to find how many circular primes there are below 1 million (should be 55), ❔ WPF Cannot find child when it's thereHi! I am working on my own RoundedCorners attachedproperty however I have stumbled upon a problem Pr❔ HttpClient exiting program during GetStringAsync() and GetAsync()I'm sending a GET to an API, but when debugging, as soon as you step off the last line, it cuts out ✅ Homework Helphttps://i.gyazo.com/f23d758d46581bcfb84f88d4178cd484.png What should I return from the FillArray() ❔ force a ushort value?if i type for example var num = 25L; i am forcing a long value (int64) how can i force a ushort in ❔ Doing post method with entity frameworki'm making a simple API to practice with entity framework but when i try to make a post to a table w