在的先前版本中,我用鼠标右键单击项目,添加文件,然后可以创建一个文件名"Web Service(asmx)",然后创建我的Web服务和所需的differents函数.
With previous version of , I used right click on project , add file and then I can create a file name "Web Service(asmx)" and then I create my webservice and differents function needed.
但是我不明白如何在新的projet 内核上为项目创建相同的文件?
But I don't understand how on a new projet core, I create the same files to my project?
预先感谢您的帮助
推荐答案在Asp Core中,没有单独的Web Api或Web表单,只有ASP.Net Core MVC.
In Asp Core there are no separate Web Api's or Web forms, there is just ASP.Net Core MVC.
Api的实现方式与使用控制器和操作的MVC相同.您只返回响应而不是视图.或者,如果您仍然可以返回包含响应的视图. . 例如
Api's are implemented in the same way as MVC using controllers and actions. You just return the response instead of view. Or if you can still return the view containing the response. . For example
[HttpGet("{id}", Name = "GetTodo")] //Name used when calling the api public IActionResult GetById(string id) { var item = TodoItems.Find(id); if (item == null) { return NotFound(); } return new ObjectResult(item); }这些API可以像asmx一样通过Http调用.您不再需要asmx.有关更多信息,请参见链接
These API's can be called through Http just like asmx.You dont need asmx anymore. For more info see this link
更多推荐
Asp.net Core并创建一个Web服务(asmx)
发布评论