$.ajax({
url: "/api/LiveChanges/Insert",
type: "post",
dataType: "json",
data: {
id: comid,
liveName: liveName,
liveId: liveId,
team: team,
course: course,
liveTeacher: liveTeacher,
livePrincipal: livePrincipal,
liveProperty: liveProperty,
liveState: liveState,
liveRemark: liveRemark
},
headers: headers,
success: function (data) {
layer.close(loading);
if (data.code == 1) {
layer.alert(data.message, { closeBtn: 0 }, function (index) {
location.reload();
});
} else {
layer.alert(data.message);
}
}
});
403是Forbidden
比如有身份,但是身份没有足够的权限。一般来说,和你这个发起请求的代码没什么关系,要从服务端排查。
[HttpPost]
public IActionResult Insert()
{
try
{
var liveName = Request.Form["liveName"].TryParseByInt(0);
var liveId = Request.Form["liveId"].TryParseByInt(0);
var team = Request.Form["team"].ToString();
var course = Request.Form["course"].ToString();
var liveTeacher = Request.Form["liveTeacher"].ToString();
var livePrincipal = Request.Form["livePrincipal"].TryParseByInt(0);
var liveProperty = Request.Form["liveProperty"].TryParseByInt(0);
var liveState = Request.Form["liveState"].TryParseByInt(0);
var id = Request.Form["id"].TryParseByLong(0);
var liveRemark = Request.Form["liveRemark"].ToString();
var model = new Live_change
{
Id = id,
LiveName = liveName,
LiveId = liveName,
Team = team,
Course = course,
LiveTeacher = liveTeacher,
LiveState = liveState,
LivePrincipal = livePrincipal,
LiveProperty = liveProperty,
AuditOpinion = liveRemark,
Type = 0,
LoginUserId = _web_Util.LoginUser.UserID,
};
if (id != 0)
{
var frontLivePrincipal = _daoLive_Change.Get(model.Id).LivePrincipal;
if (frontLivePrincipal != model.LivePrincipal)
{
var text = "申请";
InsertLogTeacher(model, frontLivePrincipal, text);
}
}
var result = id > 0 ? _daoLive_Change.Update(model) : _daoLive_Change.Insert(model);
//重新提交并通知合规经理
if (id == 0)
{
QWMessage();
}
if (result != null)
{
InsertLog(result, id);
}
return Ok(new { code = result != null ? 1 : 0, message = result != null ? "保存成功" : "保存失败,请稍后重试" });
}
catch (Exception e)
{
return Ok(new { code = 0, message = e.ToString() });
}
}这是控制器代码
@断点小白: 你这是业务代码。要看鉴权部分的代码 ,一般写在过滤器或者中间件里,关键字Authorize
@复制粘贴机器人: 感谢,解决了