Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net net核心中的邮政服务_.net_Api_Post_Core - Fatal编程技术网

.net net核心中的邮政服务

.net net核心中的邮政服务,.net,api,post,core,.net,Api,Post,Core,我正试图在VisualStudio中编写非常简单的多平台应用程序(iOS和Android)。此应用程序使用web服务,上载到我的web主机上 这是调用Web Api(获取和发布)的代码: 这是非常简单的Web Api代码: [HttpGet] public ActionResult<string> Get() { return "get method ok"; } [HttpP

我正试图在VisualStudio中编写非常简单的多平台应用程序(iOS和Android)。此应用程序使用web服务,上载到我的web主机上

这是调用Web Api(获取和发布)的代码:

这是非常简单的Web Api代码:

        [HttpGet]
        public ActionResult<string> Get()
        {
            return "get method ok";
        }


        [HttpPost]
        public ActionResult<string> Post()
        {
            return "post method ok";
        }
[HttpGet]
公共行动结果获取()
{
返回“get method ok”;
}
[HttpPost]
公共行动结果公告()
{
返回“post方法确定”;
}
非常奇怪的问题,因为对于每个空白,我总是获得“get method ok”。所以“get”是可以的,但我不明白为什么我不能调用post方法。 我试着用邮递员:同样的问题

有什么想法吗

谢谢

编辑:

我使用的代码非常简单:

[ActionName("getmet")]
    public ActionResult<string> getmet()
    {
        return "get method ok";
    }

    [ActionName("postmet")]
    public ActionResult<string> postmet()
    {
        return "post method ok";
    }
[ActionName(“getmet”)]
公共行动结果getmet()
{
返回“get method ok”;
}
[行动名称(“邮戳”)]
公众行动结果邮戳()
{
返回“post方法确定”;
}
现在,我当然可以打电话或邮递,它的工作使用邮递员。 我现在有一个问题:如果我使用[HttpPost]作为PostMethod,在Postman上我会得到“404NotFound”。为什么?

URL通过difualt点击get方法,这意味着它作为工作,其中实际的post方法URL是

不要调用其他方法,而是使用如下代码

[HttpPost]
[HttpGet]
public ActionResult<string> Get()
{
    return "method ok";
}

我尝试使用以下代码使用不同的路由:
code[Route(“/getmethod”)][HttpGet]public ActionResult Get(){return“Get method ok”;}[Route(“/postmethod”)][HttpPost]public ActionResult Post(){return“Post method ok”;}代码
但没有结果(当然我叫https//mywebsite/getmethod或postmethod,至少它会给你一个类似404500的错误。请与我们分享。使用postman:mywebsite/getmethod->status 200 ok,mywebsite/postmethod->status 404 not found“404 not found”表示服务器没有与您请求的url匹配的任何内容。请检查您的路由文件和启动文件。“路由文件”是什么意思?抱歉,我对这类内容非常陌生。我只是在VS(ASP.Net core Web Api)中创建新项目并在上面编写代码。您可以共享控制器类的完整代码吗?
var BaseAddress = "https://mywebsite"; // 
[HttpPost]
[HttpGet]
public ActionResult<string> Get()
{
    return "method ok";
}
[AcceptVerbs(HttpVerbs.Get|HttpVerbs.Post)]