MVCGrid.Net icon indicating copy to clipboard operation
MVCGrid.Net copied to clipboard

Unable to assign and read value from session

Open PrasanthiPonnada opened this issue 9 years ago • 6 comments

We have implemented mvc grid in our Application. We have a requirement that we need to assign and read the session values in MVC grid config but the session is always showing as null even we have session in our application. Can we assign and read the session values in mvc grid?. We are stuck at this point, Can any body please help us asap.

PrasanthiPonnada avatar Dec 29 '16 09:12 PrasanthiPonnada

Can someone please look into this issue

PrasanthiPonnada avatar Jan 04 '17 06:01 PrasanthiPonnada

This would be possible but the dll would need to be recompiled with IRequiresSessionState implemented on the MVCGridHandler like this: public class MVCGridHandler : IHttpHandler, IRequiresSessionState

joeharrison714 avatar Mar 08 '17 03:03 joeharrison714

Why don't you add this as default? I think many users needs to access HttpContext inside MvcGridConfig. There shouldn't be need to do a custom build just for single inheritance.

hasangursoy avatar Feb 25 '18 17:02 hasangursoy

I need the same thing, tryed to put Httpcontext to get current session and I get a null value.

ctpaula avatar Sep 28 '18 23:09 ctpaula

Hello, Any solution for this issue? Regards,

icemancyber1981 avatar May 29 '19 14:05 icemancyber1981

@joeharrison714 suggested a solution that works so I'll elaborate on it.

Disclaimer: all references here are from the project as of 2019.12.31

  1. Fetch an instance of the MVCGrid.Net project from https://github.com/joeharrison714/MVCGrid.Net

  2. Go to the MVCGridHandler file located at MVCGrid\Web\MVCGridHandler.cs

  3. Have MVCGridHandler inherit from the IRequiresSessionState by adding a using reference to the System.Web.SessionState namespace such that lines 16-20 are rewritten as:

using System.Web.SessionState;

namespace MVCGrid.Web
{
    public class MVCGridHandler : IHttpHandler, IRequiresSessionState

ZackMartinez avatar Dec 31 '19 15:12 ZackMartinez