【发布时间】:2018-04-12 07:18:30
【问题描述】:
多次点击后,Web API 控制器停止加载,但当我从 IIS 重新启动它时它开始工作。
我正在浏览器中测试 API。
这是我的控制器,带有 2 个凭据查询字符串:
[System.Web.Mvc.OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)]
public class TestController1 : ApiController
{
[HttpGet]
public HttpResponseMessage TestController1(string Username, string Password)
{
bool isvalid;
string id = string.Empty;
isvalid = //cheking credentials;
if (isvalid)
{
var obj = //getting data from DB;
if (obj.Count == 0)
{
HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.NotFound)
{
Content = new StringContent(string.Format("Data not found", id)),
ReasonPhrase = "Localized message Data not found!"
};
return msg;
}
else
{
return Request.CreateResponse(HttpStatusCode.OK, obj);
}
}
else
{
HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.Unauthorized)
{
Content = new StringContent(string.Format("UserName or Password is Invalid")),
ReasonPhrase = "Identity not found!"
};
return msg;
}
}
}
【问题讨论】:
-
检查您的浏览器调试的网络部分,并在此处发布请求和响应,以便我们能够帮助您先生
标签: c# .net asp.net-mvc asp.net-web-api