HTTP响应将返回引号字符

时间:2014-06-17 01:51:55

标签: 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 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."

除了擦除开头和结尾引号字符的消息之外,还有更多的语义/清洁方法吗?

0 个答案:

没有答案