Reputation: 6452
I created a new "asp.net core web application" project. NOT MVC!.
i see in the stratup.cs, in configure method:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
question a: the url mapped directly to razor pages ('/Index' => /Pages/Index.cshtml). and there is no IController in the entire project, What the routing of MVC doing here?
quetstion b: if i want additionaly custom routing, can I do this without turn all routing to MVC methodology?
Upvotes: 0
Views: 162
Reputation: 3342
Razor pages are a feature of ASP.Net MVC, hence the dependency on certain services and middleware, but they offer a lightweight alternative to the traditional Model-Controller-View approach. A Razor view represents the View and a code-behind class represents the Model and Controller.
By convention:
/Pages/Index.cshtml routes to / or /Index
/Pages/Contact.cshtml routes to /Contact
/Pages/Store/Contact.cshtml routes to /Store/Contact
For a full answer, you should probably read the documentation.
Upvotes: 1