Asp.net Core并创建一个Web服务(asmx) [英] Asp.net Core and create a webservice (asmx)

查看:3084
本文介绍了Asp.net Core并创建一个Web服务(asmx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.net的先前版本中,我用鼠标右键单击项目,添加文件,然后可以创建一个文件名"Web Service(asmx)",然后创建我的Web服务和所需的differents函数.

With previous version of .net, 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 .net内核上为项目创建相同的文件?

But I don't understand how on a new projet .net core, I create the same files to my project?

预先感谢您的帮助

推荐答案

在Asp.net Core中,没有单独的Web Api或Web表单,只有ASP.Net Core MVC.

In Asp.net 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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆