MVC4 automatically generate code project comments

Source: Internet
Author: User

Creating a project Asp.netmvc4web application with the project template for the VS2012 tool will generate some code including the database by default, note that if the system is not sql2012express, the database cannot be generated automatically, its login buttons and the modules created later cannot be manipulated. It's just an empty schema. The normally generated database is within the App_Data folder.

MVC4 and Webfrom's URL is different, he is through the URL route routing rather than document path access, you can see from the App_start\rounteconfig.cs document RegisterRoutes method: Routes. Ignoreroute ("{resource}.axd/{*pathinfo}"); setting the format or address that does not need to run through MVC , you can write the WebForm aspx file path to the parameter, then they can run on the same platform. If this file does not exist, in the URL to guide the path of this file will be displayed when the absence or error! Same routes. Ignoreroute ("Home/about"), nor does it carry out guidance.

650) this.width=650; "Width=" "height=" 398 "title=" Sujerhy "style=" width:700px;height:398px; "alt=" Wkiol1rqtg2wuhj3aahkx2hi3i0409.jpg "src=" http://s3.51cto.com/wyfs02/M02/4D/5F/ Wkiol1rqwpxr0nyeaagqicqgrmq440.jpg "border=" 0 "vspace=" 0 "hspace=" 0 "/>

Routes. Maproute defines a URL routing method, where three parameter variables represent three routes:

1. Name: "Default", the name of the route.

2. URL: "{controller}/{action}/{id}", set the corresponding controller (Conraoller), action, and route value (ID) for the URL path. According to the URL parameters to find the corresponding controller and action method.

3. defaults:new {controller = "Home", action = "Index", id = urlparameter.optional}. If the URL does not pass any parameter values, then the third parameter is used instead of the value in the second parameter, with the default value set.

The controller has a dynamic type object: ViewBag, you can set any object into the Viewbag.message, its properties and values can be read in the view. Settings in view @{viewbag.title = "about";}, read

Load the _viewstart.cshtml file before all view runs, code: Layout = "~/views/shared/_layout.cshtml"; Open this document discovery is a complete HTML file, Somewhat similar to the functionality of the MasterPage parent template.

Create the data Model Shift+alt+c, define the data model, F6 build the solution, create the controller, actions, and Views: Ctrl+m+c fill in the contents of the dialog box:

650) this.width=650; "Width=" "height=" 362 "title=" Sujery "style=" width:500px;height:362px; "alt=" wKiom1RQV5mRwT_ Qaaflugkhcdu161.jpg "src=" http://s3.51cto.com/wyfs02/M02/4D/5E/wKiom1RQWCujK6bRAAFRf9eJ9CY871.jpg "border=" 0 " Vspace= "0" hspace= "0"/>

Adding a controller to the process adds a new data context class MVC ..... Context.cs. The view-related paging file is also generated automatically.

This article from "Run small snail-original Space" blog, reproduced please contact the author!

MVC4 automatically generate code project comments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.