ASP. NET Web API Learning (i)

Source: Internet
Author: User

Development environment: WIN10, developed using VS2015 Community Edition and SQLSERVER2012

1. Open the VS2015 application and click on the top left button: file--New--project, pop-up window to select the ASP.

2. Click the "OK" button and a window will pop up to select the project template, VS2015 will automatically create the project folder based on the selected template and introduce some core applications, if you have not designed the project file allocation, we recommend the use of templates. When you select the "OK" button, VS will automatically create the project directory.

3. Look at the automatically generated project files, mainly divided into app_start,areas,content,controllers,models,scripts,views, etc.,
where App_start folder of several files: 1.bundleconfig.cs used to register JS and CSS;

2.filterconfig.cs is used to register the global filter;

The 3.identityconfig.cs website allows external users to register when they register;

4.routeconfig.cs Register the action contained in the Controller;

5.startup.auth.cs is used for the initial operation of the project configuration, such as user login settings;

6.webapiconfig.cs, register the Web API.

You can see the 1,2,4,6 4 items in the global profile Global.asax

namespace webapidemo{    publicclass  WebApiApplication:System.Web.HttpApplication    {         protected void Application_Start ()        {            arearegistration.registerallareas ();            Globalconfiguration.configure (webapiconfig.register);            Filterconfig.registerglobalfilters (globalfilters.filters);            Routeconfig.registerroutes (routetable.routes);            Bundleconfig.registerbundles (bundletable.bundles);     }}}
View Code

4. Create a new class in the Models folder for testing, and then create a new Employeecontroller in controllers to inherit Apicontroller. VS2015 provides a more convenient way to create a controller, in the selected folder right-click-Add-Controller, will jump out of the window to select the generated code template.

5. Run the project and click "API" on the successful Project home page to see all the Web API interfaces you have set up.

ASP. NET Web API Learning (i)

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.