- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
http://localhost:1042/Home/About in Visual C#
http://localhost:1042/Home/About Code 39 Full ASCII Maker In C#.NET Using Barcode generator for .NET Control to generate, create Code 3 of 9 image in .NET framework applications. ANSI/AIM Code 39 Reader In C#.NET Using Barcode scanner for .NET framework Control to read, scan read, scan image in VS .NET applications. The http://localhost:1042 part of the URL is a Web server that is built into VS and runs the Web application without needing a Web server such as Internet Information Server (IIS) The number 1042 is a random port number generated by the Web server, and your port number is likely to be different Drawing Bar Code In C# Using Barcode maker for Visual Studio .NET Control to generate, create barcode image in .NET applications. Bar Code Reader In Visual C# Using Barcode decoder for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications. Microsoft Visual Studio 2010: A Beginner s Guide TIP
Printing Code 3/9 In .NET Framework Using Barcode creation for ASP.NET Control to generate, create USS Code 39 image in ASP.NET applications. Print USS Code 39 In .NET Using Barcode generation for .NET framework Control to generate, create Code39 image in VS .NET applications. You can change your VS Web server s port number If you open your project s property page by right-mouse clicking on the project in Solution Explorer and select Properties, then select the Web tab on the left, under Servers, you can specify a specific port or make other Web server choices Code 39 Printer In VB.NET Using Barcode generator for .NET framework Control to generate, create Code 3 of 9 image in .NET framework applications. Encoding GTIN - 13 In Visual C#.NET Using Barcode drawer for .NET framework Control to generate, create UPC - 13 image in .NET applications. For ASPNET MVC, the important part of the URL is /Home/About Home is the name of the Controller, and ASPNET MVC appends Controller to the URL name, looking for the HomeController class, shown in Listing 9-1, physically located in the Controller folder, which is why it s important to ensure you create files in the proper locations About is an action, which corresponds to the About method shown in Listing 9-1 Similar to the About method, the Index action is run through the following URL: Print Barcode In Visual C# Using Barcode creation for .NET framework Control to generate, create barcode image in VS .NET applications. ANSI/AIM Code 128 Generation In C# Using Barcode creator for .NET framework Control to generate, create Code 128 Code Set B image in Visual Studio .NET applications. http://localhost:1042/Home/Index
Matrix Barcode Generator In Visual C# Using Barcode maker for VS .NET Control to generate, create Matrix 2D Barcode image in .NET applications. Painting UPC-E Supplement 5 In C# Using Barcode creation for .NET framework Control to generate, create UPC - E0 image in .NET applications. In a later section of this chapter, you ll learn how ASPNET MVC performs routing, which maps URLs to Controllers Both the Index and About actions in Listing 9-1 invoke a method named View This is a convention for invoking a View with the same name as the action method For example, calling View in the Index action will show a View named Index, and the call to View in the About method will show a View named About One more item to point out is how the Index action assigns a string to a collection called ViewData The ViewData collection is one way for a Controller to pass Model data to a View I ll cover more on Controllers, including how to create your own, in a later part of this chapter, but now, let s do a quick review of Views so that you can see what happens when they are invoked by the Controller Linear 1D Barcode Drawer In VB.NET Using Barcode maker for Visual Studio .NET Control to generate, create 1D Barcode image in .NET framework applications. Code 39 Full ASCII Maker In None Using Barcode encoder for Online Control to generate, create Code 39 Full ASCII image in Online applications. Displaying Views
Data Matrix Decoder In Visual Basic .NET Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications. Read Bar Code In Visual C#.NET Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications. A View is what displays in the browser and allows interaction with the user The View can display any information that a Controller passes to it For example, notice that the Index action in Listing 9-1 assigns a string Welcome to ASPNET MVC! with the Message key in the ViewData collection Print Barcode In None Using Barcode encoder for Office Word Control to generate, create bar code image in Microsoft Word applications. Encode DataMatrix In None Using Barcode generation for Online Control to generate, create ECC200 image in Online applications. Looking Inside a View
Recognizing DataMatrix In None Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications. Generating DataMatrix In None Using Barcode encoder for Excel Control to generate, create ECC200 image in Office Excel applications. Figure 9-3 shows the View in the browser, displaying the message Listing 9-2 shows the Hypertext Markup Language (HTML) of the View displaying the message The View actually has a combination of HTML and ASPNET markup, sometimes referred to as ASPX, but I ll refer to it as just HTML for the rest of the chapter 9: Creating Web Applications with ASPNET MVC
Listing 9-2 A View s HTML
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/SiteMaster" Inherits="SystemWebMvcViewPage" %> <asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server"> Home Page </asp:Content> <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> <h2><%= HtmlEncode(ViewData["Message"]) %></h2> <p> To learn more about ASPNET MVC visit <a href="http://aspnet/mvc" title="ASPNET MVC Website"> http://aspnet/mvc </a> </p> </asp:Content> A quick overview of Listing 9-2 shows that there is a Page directive with a couple of Content containers The Page directive specifies a MasterPage and Inherits attributes A MasterPage is a separate file that holds common HTML that can be shown on all pages of a site You ll see how the MasterPage works soon, but let s stay focused on the current file in Listing 9-2 until then ASPNET MVC will compile this HTML into code behind the scenes, and the generated code will derive from the class defined by the Inherits attribute The first Content container can hold metadata that goes into an HTML header The second Content container has the information that will display on the screen Notice the HtmlEncode(ViewData["Message"]) inside of binding tags <%= and %> Any time you add code or need to access ViewData that was passed by the Controller, you will use the binding tags Encode is one of several helper methods of the Html class, more of which you ll see soon The purpose of Encode is to translate HTML tags into their encoded representations for security purposes, ensuring that you don t show any harmful JavaScript, or other markup that could possibly execute, to the user ViewData["Message"] should be familiar, as it was set in the Index action in Listing 9-2 but is now being read and displayed on the screen by this View
|
|