gpt4 book ai didi

asp.net - 如何在没有 ASP.NET MVC 的情况下使用 WebAPI?

转载 作者:行者123 更新时间:2023-12-02 10:00:10 26 4
gpt4 key购买 nike

我想将 WebAPI 用于我的现有项目(经典 ASP.NET),但据我所知,您只能将 WebAPI 与 MVC 结合使用。

是否可以将 WebAPI 与 ASP.NET 一起使用?

最佳答案

来自linked page :

Although ASP.NET Web API is packaged with ASP.NET MVC, it is easy to add Web API to a traditional ASP.NET Web Forms application. This tutorial walks you through the steps.

To use Web API in a Web Forms application, there are two main steps:

Add a Web API controller that derives from the ApiController class. Add a route table to the Application_Start method. Create a Web Forms Project

Start Visual Studio 2010 and select New Project from the Start page. Or, from the File menu, select New and then Project.

In the Templates pane, select Installed Templates and expand the Visual C# node. Under Visual C#, select Web. In the list of project templates, select ASP.NET Web Application. Enter a name for the project and click OK.

关于asp.net - 如何在没有 ASP.NET MVC 的情况下使用 WebAPI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10306620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com