几次点击后,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;
}
}
}
答案 0 :(得分:0)
尝试从$(e.relatedTarget)
删除所有功能,然后返回确定。如果仍然失败,请尝试捕获/查找任何异常 - 可能在IIS日志中。
如果在没有您的功能的情况下工作,请再次按步骤启用它。一次启用TestController1
和//cheking credentials;
一个。也许你有内存消耗问题?