Asp.net B2C和Azure应用程序服务的CORS问题

Asp.net B2C和Azure应用程序服务的CORS问题,asp.net,cors,azure-ad-b2c,Asp.net,Cors,Azure Ad B2c,我在ASP.NET/Angular应用程序中通过在控制器中使用AddCors和EnableCors启用了CORS。我的应用程序正在与广告B2C页面通信。生成后,控制台中出现以下错误: 在“”处访问XMLHttpRequest已重定向 从“”)从源 “”已被CORS策略阻止:否 “Access Control Allow Origin”标头出现在请求的服务器上 资源 Startup.cs: services.AddCors(options => {

我在ASP.NET/Angular应用程序中通过在控制器中使用AddCors和EnableCors启用了CORS。我的应用程序正在与广告B2C页面通信。生成后,控制台中出现以下错误:

在“”处访问XMLHttpRequest已重定向 从“”)从源 “”已被CORS策略阻止:否 “Access Control Allow Origin”标头出现在请求的服务器上 资源

Startup.cs:

            services.AddCors(options =>
        {
            options.AddPolicy("CorsPolicy",
                builder => builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials());
        });
控制器:

[EnableCors("CorsPolicy")]
[Authorize]
public class UserEditController : Controller
我也在Azure上启用了CORS,方法是放置:
Allowed Origins-*

更新:

[Route("User/Info")]
[HttpGet]
public async Task<IActionResult> LoggedInUserInfo()
{
    if (User.Identity.IsAuthenticated)
    {
        var user = ((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.NameIdentifier).Value;
        var viewmodel = await userService.GetUserByObjectId(user);
        return Json(new { loggedIn = "true", user = viewmodel });
    }
    return Json(new { loggedIn = "false" });
}
[路由(“用户/信息”)]
[HttpGet]
公共异步任务LoggedInUserInfo()
{
if(User.Identity.IsAuthenticated)
{
var user=((ClaimsIdentity)user.Identity).FindFirst(ClaimTypes.NameIdentifier).Value;
var viewmodel=await userService.GetUserByObjectId(用户);
返回Json(new{loggedIn=“true”,user=viewmodel});
}
返回Json(新的{loggedIn=“false”});
}

您似乎正在尝试从域到域的跨源请求


目前,
.b2clogin.com
域不允许来自任何其他域的任何跨源请求。

Hi@Memo您是否试图从您自己的页面向
.b2clogin.com
源请求跨源请求?是的。我也在我的B2C页面上启用了CORS。尝试向b2clogin.com发出XMLHttpRequest的场景是什么?@OmerIqbal我已经更新了帖子。您可以看到该场景,该方法是查询Azure AD以获取具有对象Id的用户。