In this video, explore the code in the new project template and App_Start folder, and learn how it configures bundles, areas, and global filters for you.
- [Instructor] Now let's go back to the code and look at the other three lines of code in the global ASAX.CS file, and their corresponding files in the app start folder. We've already seen the routing configuration, so let's look at everything else that is being configured at start-up besides that. In order, the first thing we see is something called area as being registered. We won't talk a lot about these in this course, but at a high level, areas are another way to organize related functionality in an MVC5 application into groups for routing and file organization purposes. The register all areas method is a static method defined on the area registration type that actually looks through our project for areas and registers them for us automatically. If you're not using areas, then you can remove this line completely. The next line is formatted in a very similar way, but is actually running code that's defined in this project by a file located in the app start folder. If we navigate to that file, it's called FilterConfig.cs, you can see it simply adds filters that we want added globally to all controller actions on our project. We'll look more at filters as I mentioned later in this course, but for this project, you can see that the only global filter is one called the handle error filter, which handles any unhandled exception that bubbles up to this point. Going back to the application start method, our next line calls route config which is the one we already looked at in some detail, so I'll skip that. Finally, there's a line of code that is registering something called bundles. We can see this code defined in the bundle config, that CS class located in app start. Bundles are a way to combine static resources, such as Java Script and CSS files into a single download for performance reasons. There are both script and style bundles and when you define either, you give it a path that it will respond to, like /bundles/jquery in this case, then you tell ASP.NVC what files to include in that bundle. In this case, we're looking for all of the JS files under the scripts folder that begin with jquery/ followed by some version number. All of our script and style bundles are defined in a similar way, and allow us to have a more speedy download of those files, and therefore a much more speedy web application. Now you should understand all of the code that is in the app start folder, and in the global ASAX file, and what each line is doing there.
- Creating a new ASP.NET MVC 5 project
- Using controllers and action methods
- Creating attribute routes
- Strongly typed models
- Building HTML with HtmlHelpers
- Sharing views
- Building models with Entity Framework
- Unit testing code