Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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
C# HTTP响应将返回引号字符_C#_Http - Fatal编程技术网

C# HTTP响应将返回引号字符

C# HTTP响应将返回引号字符,c#,http,C#,Http,我有一个API端点: [Authorize] [HttpGet] public HttpResponseMessage CheckForGameId(string name, string password) { if (name == null || password == null) { return Request.CreateResponse(HttpStatusCode.BadRequest, "One or more of t

我有一个API端点:

[Authorize]
[HttpGet]
public HttpResponseMessage CheckForGameId(string name, string password)
{
    if (name == null || password == null)
    {
        return Request.CreateResponse(HttpStatusCode.BadRequest, 
            "One or more of the method arguments was invalid.");
    }
    using (var context = new BattleGameEntities())
    {
        var lobby = context.Lobbies.FirstOrDefault(l => l.LobbyName == name 
            && l.StartedOn == null 
            && !l.AttemptedRemoval);
        if (lobby == null)
        {
            return Request.CreateResponse(HttpStatusCode.NotFound, 
                "No lobby could be found that matched those credentials.");
        }
        if (password == lobby.Password)
        {
            return Request.CreateResponse(HttpStatusCode.OK, lobby.LobbyId);
        }
    }
    return Request.CreateResponse(HttpStatusCode.NotFound, 
       "No lobby could be found that matched those credentials.");
}
我可以很好地得到响应,但是,我的响应对象的responseText属性有如下值:

""No lobby could be found that matched those credentials.""
"No lobby could be found that matched those credentials."
当我希望它看起来像这样时:

""No lobby could be found that matched those credentials.""
"No lobby could be found that matched those credentials."

除了清除开头和结尾引号字符的消息外,还有其他语义/更清晰的方法吗?

我运行了它,我可以看到带有单双引号的正确返回值。在调试器中,您在哪里看到这些双引号?您解决过这个问题吗?我自己也遇到了这种奇怪的行为。不幸的是没有,我只是为字符串原型编写了一个扩展方法来修复它。