I am learning my way around an MVC 4 application but am new to the mvc platform. If I were learning a new java application, I would start reading code from the main method and go from there. What is the analog for an asp.net mvc application?
I launch the application from the following URL: http://server/directory/home?iv-user=tuser
The Main() method is the entry point in a . NET or a . NET Core application. Because Main() is the entry point of your application, you can have one and only one Main() method in your project.
The view is the entry point to the Application. One to many relationships between Controller & View.
In this article. ASP.NET MVC 4 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of the ASP.NET and the . NET framework. This new, fourth version of the framework focuses on making mobile web application development easier.
The Global.asax.cs
file, where there is the start method Application_Start
might be what you are looking for. That is the code which is run when the app starts.
protected void Application_Start()
{
...
RouteConfig.RegisterRoutes(RouteTable.Routes);
...
}
But looking at the url you have posted it might be the HomeController
or DirectoryController
file. Unfortunately, I cannot tell that from looking at your route.
A sample route register code is as below where we can see that
The URL /{controller}/{action}/{id}
The default for controller/action/id is Home/Index/optional
So if you run your web with the starting url as http://localhost:52763/
, it is indeed will call http://localhost:52763/Home/Index
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
It's HTTP. You make a request to the web server for a resource, as you have specified above, and the controller responds.
So in ASP.NET MVC, you have multiple entry points: each action method.
MSDN Controllers and Action Methods in ASP.NET MVC
There is an application_start()
method in global.asax.cs.
As for the controller's concern for the request, its starts in the constructor of the controller then the method for the requested action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With