Asp.net Core and create a webservice (asmx) [duplicate]

狂风中的少年 提交于 2019-12-04 21:04:23

In Asp.net Core there are no separate Web Api's or Web forms, there is just ASP.Net Core 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);
}

These API's can be called through Http just like asmx.You dont need asmx anymore. For more info see this link

ASMX as a technology has been supplanted with newer things in .NET, such as MVC and WebAPI. I'd look into using one of these (probably WebAPI) to create web services in .NET core.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!