Closed meninjanho4788 closed 7 years ago
That's a bit vague. Are these two different Actions, Controllers, or completely separate applications?
Yes, i have two controller : AccountController(api/account/registry) is set Session and AuthorizationController(connect/token) is get Session, and it in same application.
I try Set and Get Session in AccountController it have value. but when Get in other controll it null
My code : AccountController
[HttpGet("ExternalLoginCallback")]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{ ....
HttpContext.Session.SetString("MySession", info.ProviderKey);
...
}
AuthorizationController :
[HttpPost("~/connect/token"), Produces("application/json")]
[AllowAnonymous]
public async Task<IActionResult> Exchange(OpenIdConnectRequest request)
{
var dataSession = HttpContext.Session.GetString("MySession");
//dataSession is null
}
My Setting in Status.cs :
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(options =>
{ options.Filters.Add(typeof(ModelValidationFilter)); })
.AddJsonOptions(options =>
{ options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; });
services.AddMemoryCache();
services.AddSession();
}
public void Configure(IApplicationBuilder app)
{
app.UseSession();
app.UseMvc(routes =>
{
routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" });
});
}
Many thank you. I need n't use session in API because it will make my application vulnerable to this class of attack. I will try other way.
My English is not good !
I use netcore, i have two API, one API Set Session value HttpContext.Session.SetString("GoogleProvider", info.ProviderKey);
And one API get this session but result is null. HttpContext.Session.GetString("GoogleProvider");