joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Unable to assign and read value from session #84

Open PrasanthiPonnada opened 7 years ago

PrasanthiPonnada commented 7 years ago

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 commented 7 years ago

Can someone please look into this issue

joeharrison714 commented 7 years ago

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

hasangursoy commented 6 years ago

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.

ctpaula commented 5 years ago

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

icemancyber1981 commented 5 years ago

Hello, Any solution for this issue? Regards,

ZackMartinez commented 4 years ago

@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