我使用jquery(ajax)连接到返回字符串的Web服务,它不能与我合作。它总是去错误功能。这是我的网络服务:
SELECT A1.ID_USER,
A1.CNAME,
(SELECT CNAME
FROM
(SELECT CNAME,
COUNTER
FROM
(SELECT id_Category AS IDCATEGORT,
COUNT(*) AS COUNTER
FROM gamescateg
WHERE id_game IN
(SELECT ID_GAME
FROM UserGames
WHERE id_user=UsersGamers.ID_USER --replaced A2 with UsersGamers
)
GROUP BY id_Category
)
JOIN Categories ON id_Category =IDCATEGORT
ORDER BY COUNTER DESC
)
WHERE rownum = 1
) AS FAVORITECATEGORY
FROM UsersGamers A1
JOIN UsersGamers A2 ON A1.ID_USER= A2.ID_USER
这是我的js代码:
[HttpGet]
[ActionName("GetImage")]
public string GetImage(string base64String, string imgName,string reqTitle , string reqSubject, string reqStatus,string Creator , DateTime creationdate )
{
try
{
using (PhMobAppEntities context = new PhMobAppEntities())
{
ClaimsApproval _ca = new ClaimsApproval();
_ca.imageBasestrg = base64String;
_ca.imageName = imgName;
_ca.Creator = Creator;
_ca.CreationTime = creationdate;
_ca.ReqStatus = reqStatus;
_ca.ReqTitle = reqTitle;
_ca.ReqSubject = reqSubject;
context.ClaimsApprovals.Add(_ca);
context.SaveChanges();
return "Success";
}
}
catch (DbEntityValidationException ex)
{
var errorMessages = ex.EntityValidationErrors
.SelectMany(x => x.ValidationErrors)
.Select(x => x.ErrorMessage);
var fullErrorMessage = string.Join("; ", errorMessages);
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
}
}
当我在高级休息客户端测试我的网络服务时运行正常,请提供建议。
答案 0 :(得分:0)
我尝试连接到您的网络服务,我得到以下回复:
{"$id":"1","Message":"No HTTP resource was found that matches the request URI 'http://41.128.183.109:1212/api/Data/GetImage'."}
我认为你的c#代码存在内部问题,可能与您的路由有关。你的javascript调用可能工作正常,但你只传递一个参数,“test”,而你的声明中还有更多。
你得到什么http响应代码?