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)