C# HTTP响应将返回引号字符
我有一个API端点: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
[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."
除了清除开头和结尾引号字符的消息外,还有其他语义/更清晰的方法吗?我运行了它,我可以看到带有单双引号的正确返回值。在调试器中,您在哪里看到这些双引号?您解决过这个问题吗?我自己也遇到了这种奇怪的行为。不幸的是没有,我只是为字符串原型编写了一个扩展方法来修复它。