breaks all incoming requests into three segments a URL segment is anything

Breaks all incoming requests into three segments a

This preview shows page 18 - 31 out of 40 pages.

breaks all incoming requests into three segments (a URL segment is anything between forward slashes). The first segment is mapped to a controller name, the second segment is mapped to an action name, and the final segment is mapped to a parameter passed to the action named Id. Default Routes 18
Image of page 18
Controllers
Image of page 19
HomeController.cs
Image of page 20
Controllers Cont Developers need to be aware of the fact that any public method is exposed as a controller action. This means that any public method contained within a controller can be accessed by entering the appropriate URL into a browser. 21
Image of page 21
Views
Image of page 22
Views If you want to return a view from a controller action, you need to create a sub folder in the Views folder with the same name as the controller. In this subfolder you need to create an .cshtml file with the same name as the controller action.
Image of page 23
Index.cshtml
Image of page 24
Index.cshtml page 25
Image of page 25
Razor View Engine
Image of page 26
Razor views use a layout to determine their look and feel The default view is held in Views/Shared/layout.cshtml . Layouts
Image of page 27
Image of page 28
Image of page 29
@Styles.Render("~/Content/css") is rendered as <link href="/Content/site.css" rel="stylesheet"/> The lines @Scripts.Render("~/bundles/modernizr") @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstraps") are rendered as <script src="/Scripts/modernizr-2.8.3.js"></script> <script src="/Scripts/jquery-3.3.1.js"></script>
Image of page 30
Image of page 31

You've reached the end of your free preview.

Want to read all 40 pages?

  • Three '18
  • Staff
  • World Wide Web, .NET Framework, Web Accessibility Initiative, asp.net mvc framework, Default MVC Project

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture