Hey, I have a few years experience with c# in Unity, I figured my experience would transfer over to learning MVC pretty easily, and boy was I wrong. I was following Mosh’s course on MVC and I hit a brick wall pretty quickly. As soon as he got into the routing and regex stuff, and file stuff I was just stunned. The way he casually talks about it seems like its assumed that it’s a pre-requisite. So my question is two-fold - A.) I can’t find any Mosh courses that talk about Regex aside from the SQL one, so is that where the topic of Regex is brought up? B.) what are the pre-requisites before MVC? Should I have done SQL first? Should I also do datastructures first? I know a few algorithms and all the main datastructures from doing game dev for 3 years so I figured I didn’t need to do that.
Honestly, Mosh’s ASP.NET MVC course is outdated. There have been a lot of changes to make .NET development easier and making the development experience better since Mosh released his course. You will be much better off watching a more up-to-date tutorial or course from someone like IAmTimCorey on YouTube regarding ASP.NET.
thanks for the reply, the tim corey one however seems to be from 2017, even older than mosh’s
What you mention is a trait of many highly skilled people. Because of their ease in their domain, that naturally speak of advanced topics casually. So on your end it may look like a prerequisite. Sometimes some of them go the “you should know that” which is neither exactly true nor constructive.
As of Mosh, I think he has a very good pedagogy and outdated courses are not a big deal. I see this as an occasion to do my own research.
I realize afterwards that my answer is for Web API which I am more used to but the link bellow still applies.
For MVC the difference is minimal. Actions take the name of corresponding views and you can use extra parameters to state which view to use if needs be.
Indexis the default action which will display the
Views/Books/Index.cshtmlpage. It would correspond to the
AnotherPagewould by default display
Views/Books/AnotherPage.cshtmlwhich corresponding URL would be
You can check routing @MSDN.
In a nutshell you divide it in controller (which is a class) and actions (which is how methods are called in the context of ASP controllers).
Actions follow a naming convention in which you prefix the action with one of the HTTP verbs (GET, POST, PUT, UPDATE, DELETE, you name it).
You can also use attributes to precise to what verb an action is related.
So if your controller is
BooksController with a
GetBooks() action that retrieves a list of books.
You may access your ressource at
GetBooks() action will be reached if the request has the
GET HTTP verb.
Now you will likely need another method to get a specific book.
Classical way is by using an integer
id which is given in the URL and then passed to the action.
The URL would look something like
https://mysite.com/Books/5 also on the
GET HTTP verb.
The corresponding action signature would be
POST it would be
PUT it would be
and so on.
Hopefully I helped a bit to introduce you to routing.
I hardly ever use Regex so I can’t help much. I would simply RTFM @MSDN should I ever need it. Now regex has nothing in particular to do with SQL (Server) whatsoever. Regex is a syntax in which a pattern is used to filter/modify a string basically.
Usually working with Web API involves persisting data but as far as I can remember you have all you need in Mosh course with introduce Entity Framework. On ASP .NET MVC you can use a local database (I think even if SQL Server is not installed on your computer). All you need along with the appropriate connection string is the App_Data folder available otherwise you’ll get an exception at startup. I used to create it manually but actually VS has an option in the menu to add special folders.
Same goes for Identity. Later in the course Mosh happily goes like “Hey you know what? Now we need Identity and I did not add it on purpose”… At the time I took the course I tried to find a solution and on SO they proposed to create a new project with identity and manually copy the extra files… Not that much difficult but still quite delicate operation.
I found out later that there is a way to scaffold the code.
It will install the NuGet package for code generation.
Then you can choose what is to be scaffolded.
I created an ASP .NET Core project for the sake of taking these screenshots for I could not create an ASP .NET MVC project anymore due to unresolved packages. But it worked the same.
You may have enabled Identity without noticing because some version of VS did that by deault but in case of you’ve got a hint.
Should you have more specific questions, please ask.