first time i respond on stackexchange like Email form
my question is not about aspx pages, its about asp.net core MVC6 asp.net core can do without aspx pages, it uses Razor pages. Another reason for not removing this question is for helping other students like me who endup with the same question i had based on this course, as i later found the proper words, there are various websites where people seam confused about this, and while i adept to this new concept. I hope you can keep the question more people following the Microsoft online course can stumble into this, as on the video its not realy clear. (lots of things are discussed and this is quite a big one between all the other explanations in that movie).
At some point in this course video, they have defined a Controller that responds to an URL. MVC somehow understands when you request http://localhost/Scott
, that it should call the ScottController
which then returns "hey it's scott".
The controllers look like this:
namespace WebApplication1.Controllers // dont use controller minus S (controller) here
{
public class MariaController
{
public string Index() => "Hello from index mvc";
public string Maria() => "Hello from Maria mvc";
}
public class ScottController
{
public string index()
{
return "hey it's scott";
}
}
}
Notice in the code above there is no [HttpGet("/Maria")]
or [HttpGet("/Scott")]
annotation, yet somehow this code knows about that the class ScottController
should respond to the /Scott
URL, despite it doesn't have a "name property" or so with the value "Scott" to check against.
Is it that with Controller classes, the name "ScottController" is split up and Controller is removed, so MVc knows this a class that handles requests to the /Scott
URI?