Last post Jun 23, 2020 02:51 PM by 0belix
Jun 22, 2020 01:13 PM|william12512512|LINK
I have built a webapp that uses Owin Authentication with Microsoft login in ASP.NET with C#.
In my login page, I ask the users with a drop down list what "world" they want to access. The user will able to view different content on the next page, depending on what world they choose. The same email login can have different users (depending on what
world is chosen), so I need to save what world they choose in the drop down list.
Normally, I would do this with cookies, but since I use Owin Authentication now, withouth cookies, how can I save this drop down option, and use at the next page?
I have tried the following:
Logic from my LoginPage
var userClaims = User.Identity as System.Security.Claims.ClaimsIdentity;
userClaims.AddClaim(new Claim("World", World.SelectedItem.Value));
Then, I try to access this claim from my Logged in application (different aspx file):
string world = userClaims?.FindFirst(System.Security.Claims.ClaimTypes.World)?.Value;
This doesn't work however. I can access my new Claim in my LoginPage, but it doesn't seem to "save" it when I redirect to a logged in view.
Jun 23, 2020 03:12 AM|XuDong Peng|LINK
According to your description, I think you could try the following two ways:
Hope this can help you.
Jun 23, 2020 02:51 PM|0belix|LINK
You could store the value in a cookie, before you start the authentication, on the client side, or you could store it also on the client side using the sessionStorage object, or also, as mentioned before by another user, store it on the Session object server
side. Of course you could also store it on a database, or on a local configs file.
After any of the previous, you just need to check the selected method on the load of the page where you are getting redirected, and act accordingly.