❔ What makes two Controllers work differently?
I am not able to take the controller of one tutorial and apply it to the sample-project of another tutorial.
Both from Microsoft.
What is it that makes this "Welcome" function break the project?
What is it that makes these two projects controllers seemingly work differently from each other?
32 Replies
Both these code snippets are found from the beginners tutorial on MVC
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Okey so plain html is an example of a primitive
Inheriting from ControllerBase and Controller are two completely different things
Not that I understand which I should start using
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
One of them uses "[HttpGet]" the other does not
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I understand
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
You are saying don't use "[HttpGet]"
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I'm guessing "[ApiController]" should only be used for APIs. But I also wan't to incorporate Razor pages into this project
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I understand that the name of the function creates the path
I meant I want this mvc-project to create html-pages using razor
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yes I accidentally used a word "Razor pages" when I was not refering to that specific thing
So if I have this api project
It's using [ApiController] and it has "ControllerBase"
Now I want it to use Razor
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I assumed I could just add some more controllers like this welcome function that would direct to a view
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I am a junior developer and i'm trying to keep up
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Is this a name "AddControllerAndView" ? Can't find it
TeBeCo
i suggest you create ELSEWHERE a separated
dotnet new mvc -n JustToLookAtIt
Quoted by
<@689473681302224947> from #What makes two Controllers work differently? (click here)
React with ❌ to remove this embed.
Yes I am forced to learn MVC
I thought I would try making projects during summer break
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
This project itself is not vital as you can see
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I made another project to compare as you said
I thought I should perhaps make another controller that inherits Controller instead
I could see what "AddControllerAndView" was, and added it to the old project
Why does it seem to think all these things already exist?
Is this what you meant? It seems like errors arose from the solution
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I made your solution work
Thank you so much @TeBeClone
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.