Last post Nov 19, 2020 04:17 PM by bruce (sqlwork.com)
Nov 19, 2020 11:24 AM|silbahi|LINK
I have a web service which returns a list of objects to me. indeed it is a list of permissions according to the logged in user which includes the modules of my application with the permissions (Visible / read / create / delete / modify)
I used this service, I got the list well and I saved it in a session at the time of Login.
To apply these permissions, I would like to access my session and know in the permissions list if the user has the right to do for example a delete or create action ..etc
How I can access my session knowing of type System.Collections.Generic.List`1 [mySolution.Models.PermissionsModel]
i develop in c #, asp.net mvc
Could you please help me on this!
Nov 19, 2020 12:16 PM|mgebhard|LINK
You should use standard programming practices when handling role/claims if you new to security.
Fetching an item from Session is very simple and covered openly in the official documentation.
List<Models.PermissionsModel> permissions = (List<Models.PermissionsModel>)Session["YourUnkownSessionKey"];
Nov 19, 2020 04:17 PM|bruce (sqlwork.com)|LINK
you question implies you have not yet learned the C# type system. You should learn enough to understand the concept of types and especially casting. You will also need to learn about generics.
if you are going to code MVC you also need to understand interfaces and the interface pattern.
please study C# a little more.
also as stated, if you had read the MVC documentation, there is a supported infrastructure for what you are trying to do.