ASP. NET Core WebApi

Source: Internet
Author: User

ASP. NET Core Webapi Create project

Use VS to create a new project and select the ASP. NET Core Webapi.

At this point, the Configure and Configureservice methods of startup are as follows:

// HTTP请求管道public void Configure(IApplicationBuilder app, IHostingEnvironment env){    app.UseMvc();}// 配置IOC容器public void ConfigureServices(IServiceCollection services){    services.AddMvc();}
Configure Routing

WEBAPI uses the Restfull request method, for the controller, the route attribute is required to configure routing, and the action in the controller is configured with the HTTP feature.

[Route("api/[controller]")]public class TodoController : Controller{    }

The route configuration in the code above uses a wildcard character [controller] , which is equivalent to Todo .

Run the project

Ctrl+f5 run the project directly in VS, F5 to debug. Because WEBAPI does not have a Web page, it needs to be requested using postman.

Publish and deploy

The generated file contains all the DLLs and static resources that the program uses to launch the program at the command line after publishing to the directory.

dotnet DemoWebApi

Due to the cross-platform nature of. NET Core, post-release programs can run on all supported platforms.

ASP. NET core Kestrel is run as a Web server and can be used in conjunction with reverse proxy servers such as IIS, Apache, Nginx, and so on.

ASP. NET Core WebApi

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.