Pregunta

I've a class library and a mvc project on the same solution. Sometimes I've access the session data when need validate rules for user access, but another times the return is "null". In my searches on internet I could not find a workable solution for this case. This problem occurs when I use a simple form to searches on a table data. You have any sugestion? Thanks for now. (Bellow my code fragment)

public class EasyLabSimpleRoleProvider: RoleProvider
{
    public override string[] GetRolesForUser(string username)
    {
        Dictionary<string, object> empresa;
        empresa = HttpContext.Current.Session["Empresa"] as Dictionary<string, object>;
        //when I use a search form, HttpContext... return null.
        //....
    }

    //....
}
¿Fue útil?

Solución 2

I solved my problem (specifically) when corrected my form, using the same javascript functions (generics) applicable to other forms in my project. I don't know the reason for the web form not work without these definitions and the session also not work consequently.

This is my solution:

@using (Html.BeginForm("Index", @controller, FormMethod.Get, new { @id = "frmFiltro", data_tiposub = "2", @class = "", role = "form" }))

Thank you very much.

Otros consejos

Try inheriting from IReadOnlySessionState too. It works when you create custom handlers, maybe could help you there too.

public class EasyLabSimpleRoleProvider: RoleProvider, IReadOnlySessionState 
{

    //....
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top