1

In this Project I have identity server(Asp.net core) ,Web application(.net Framework 4.8) and api (Asp.net Core)

api in get access token from cookie in identity server

in this web application i am get access token using this method so get access token from cookie successful

var authResult = await HttpContext.GetOwinContext().Authentication.AuthenticateAsync("cookies");
var props = authResult.Properties.Dictionary;
props.TryGetValue("access_token", out var accessToken)

but this method not working in asp.net core api

this method to not get access token from cookies

there are three same cookie available in web and api

this is a cookie name below hear

.AspNetcookies idsrv.session idsrv

api in get access token from cookie

get solution in asp.net

1 Answers1

0

In ASP.NET Framework 4.8 you can use the Request.Cookie collection

Example: var s = Request.Cookies["access_token"].Value;

identical question: here

  • Api in use Asp .net core – NamanGajjar Jun 28 '23 at 04:47
  • I am edit question in my project i get only three cookie (.AspNetcookies, .idsrv.session, idsrv) – NamanGajjar Jun 28 '23 at 04:51
  • Ah so you wanna access the cookies in the api via the http header right? What you could try is something like this. `var s = Request.Headers.GetCookies("access_token").FirstOrdDefault()?` didnt tested it by myself but it could work out. – newbeCoder Jun 28 '23 at 06:55