0

i use vue js 2 and asp.net core 2.2 on my project I use origin cors on my app and set my vue js development address to WithOrigins and on front side set {withCredentials: true } on very request

services.AddCors(o => o.AddPolicy("AllowAll", builder =>
        {
            builder
                .WithOrigins("http://localhost:8080")    
                .AllowCredentials()                       
                .AllowAnyMethod()
                .AllowAnyHeader();       
        }));

set startup to use session properly like this on ConfigureServices

services.AddSession(options =>
{
    options.IdleTimeout = TimeSpan.FromMinutes(10);

});

and use it

app.UseSession("AllowAll");

when authentication successfully with front side I must save loged in user on session and other request I need to save object on session and return on another request . I try to setString - setting and ... but when I send another request the session id changes per request and I not able to get what set on last session . any idea for another way to save status of user on something like session? I used ImemoryCache but I don't know abou life cycle or is generate unique id for every user ? any way to use session ?( I know the restful api communicate with token but I need that )

zolfaghari
  • 192
  • 3
  • 14
  • What is `app.UseSession("AllowAll")`? I think you need to use `app.UseCors("AllowAll")` for CORS policy. And for session, refer to [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-2.2#session-state), for your question also refer to [here](https://stackoverflow.com/questions/49317304/asp-net-core-2-1-session) – Ryan Dec 25 '19 at 05:54
  • @xing-zou yeah I did that but nothing changes . it's not my problem the thing is something else I ask about session and a read links you referr to me dude but not work for me I use [ options.MinimumSameSitePolicy = SameSiteMode.None;] but still not working – zolfaghari Dec 25 '19 at 08:15

0 Answers0