Reputation: 46128
When you go to the root of an ASP website (either webforms or MVC), how does the web server know which .aspx or .cshtml file to load, and which dll in the bin/
directory contains the code to execute? How does it match the two up?
Upvotes: 1
Views: 665
Reputation: 75103
I don't know if your looking for a very technical answer, or a simple overview. So, here's a simple overview.
When you go to the root of an ASP website
ASP, HTML, PHP or whatever technology you use, the Web server knows the default documents to search and show when no document was provided, for example, in Microsoft IIS Server, the default documents are:
This is the same for Apache server, there's a setting that tells the server "If you do not have a document name, use this one" setting, this one is found in .htaccess
file and has:
DirectoryIndex index.php index.html index.htm default.html default.htm home.html
In ASP.NET MVC, you work with Routing tables and it's in the Global.asax
file that the routes are mentioned, either by specifying the routes directly or call an external file (class), and the common route is:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Where this states that, if no route is provided, it will be the same as /Home/Index
.
Regarding the DLL
s part, it's all about your first document...
.NET Sites are pre-compiled and exposed their namespaces and properties, you will have in a ASP.NET Webforms, something like this in the first line of code:
<%@ Page Title="Home Page" Language="C#"
MasterPageFile="~/Site.Master"
AutoEventWireup="true"
CodeBehind="Default.aspx.cs"
Inherits="WebApplication3._Default" %>
This tells the server to run the WebApplication3._Default
inside Default.aspx.cs
and from there, it will attach any needed assemblies to run the code.
Upvotes: 5