项目为.net6,使用jwt做的认证,有一个接口不想做授权就添加了,AllowAnonymous但是无效,禁用了EnableEndpointRouting也不行
.AddMvcOptions(options=>options.EnableEndpointRouting=false);
[Route("ckeditor/upload")]
[HttpPost]
[AllowAnonymous]
[Consumes("multipart/form-data")]
public async Task<ApiResult> CkeditorUploadFile()
{
var file = Request.Form.Files[0];
string account = Auth.GetLoginUser().Account;
UploadFileDTO uploadFileDTO = await _uploadFileService.Upload(file, account);
return ApiResult.Success(uploadFileDTO);
}
有没有可能你的认证是自定义的,根本没有过滤AllowAnonymous 特性的路由呢;