小编Moh*_*man的帖子

7
推荐指数
1
解决办法
4652
查看次数

C# 响应中的“Access-Control-Allow-Credentials”标头为“”,当请求的凭据模式为“include”时,该标头必须为“true”

我在 .Net Core 6 中遇到 Cors 问题。尽管 Cors 可以与之前的版本 3.1 配合使用。我搜索了很多没有用。

完整的错误消息是

Access to XMLHttpRequest at 'https://localhost:7230/api/teachers/subjectsByTeacher?teacherId=5&pageNo=1&pageSize=10&sorting=name%20asc' from origin 'https://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

这是我的program.cs类:

var builder = WebApplication.CreateBuilder(args);

// Configure cors. …
Run Code Online (Sandbox Code Playgroud)

c# cors angular asp.net-core-6.0

-1
推荐指数
1
解决办法
2744
查看次数

标签 统计

angular ×2

asp.net-core-6.0 ×1

c# ×1

cors ×1