StatusCode:404,ReasonPhrase:“未找到",版本:1.1, [英] StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1,

查看:305
本文介绍了StatusCode:404,ReasonPhrase:“未找到",版本:1.1,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Web api selef主机:

I use Web api selef host:

public class TestController : ApiController
{
    [HttpPost]
    public void Testp([FromBody]string title)
    {
        Console.WriteLine("Post");
    }
}

这是简单的控制器这是我的客户:

this is simple controller and this is my client:

client.BaseAddress = new Uri("http://localhost:1010");
      const string englishTitle = "TesteDelete";
      var post = client.PostAsync("Test/Testp", new
      {
                    title = englishTitle
                }, new JsonMediaTypeFormatter());
                var result = post.Result;
                if (result.IsSuccessStatusCode)
                {

                }
                else
                {
                    string content = result.Content.ReadAsStringAsync().Result;

                }

为什么我的结果是:

{StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Date: Sun, 21 Apr 2013 12:00:03 GMT
  Server: Microsoft-HTTPAPI/2.0
  Content-Length: 165
  Content-Type: application/json; charset=utf-8
}}

我认为我的Modelbinder有一些错误

I thnik my modelbinder has some error

推荐答案

我想您正在使用Visual Studio Web服务器进行调试(不分昼夜地进行).该端口可以随时更改,因此我想它不再是您的URL中指定的"1010":

I'd imagine you're debugging using the visual studio web server (down by the clock). The port for this can change at any time, so I'm guessing it is no longer '1010' as specified in your URL:

"http://localhost:1010"

也许您应该在这里查看自动获取当前网址.

Perhaps you should look here to get the current URL automatically.

这篇关于StatusCode:404,ReasonPhrase:“未找到",版本:1.1,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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