When the website is loaded, there is no problem whatsoever. The "RenderAction" also works as supposed to. However when trying to navigate to no matter what other page, I'll get the error: "The provider requires session state to be enabled". I'm sure that
I have session state enabled because I use it myself.
Is anyone experiencing the same issue and found a solution for this?
Hello. well, the problem you're having is that you're trying to access the TempData on the page to which you're navigating to. As it's been discussed in the other threads, that will happen when you have session disabled. However, you say you use it yourself,
so this is a little bit strange. Do the following test: before accessing the TempData property, try setting a session variable. do you get the session on this "dumb" session access or only on the tempdata property? btw, which version of IIS are you using?
--
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
I am running into this same problem as well but I am using windsor to resolve my controllers. I do not have the session state disabled as well. I even tried adding <sessionState mode="InProc" /> in my web.config with no results either.
And put a break point on the line with "return controller" and check to see if controller.TempDataProvider is an instance of SessionStateTempDataProvider. If it's not, then perhaps Windsor is setting it to something else.
Phil Haack (http://haacked.com/)
Senior Program Manager, Microsoft
Well TempDataProvider is a new property of Controller in Preview 4. You probably just need to configure Windsor to supply SessionStateTempDataProvider when a dependency for ITempDataProvider is needed.
Phil Haack (http://haacked.com/)
Senior Program Manager, Microsoft
bartreyserho...
Member
16 Points
14 Posts
The provider requires SessionState to be enabled
Jul 24, 2008 05:28 AM|LINK
Because the thread that was dealing with this problem had evolved towards a different issue, I'll create a new thread to discuss this one.
I have a masterpage that contains the following statement:
<%Html.RenderAction<ActiveCompanyController>(c => c.List());%>
When the website is loaded, there is no problem whatsoever. The "RenderAction" also works as supposed to. However when trying to navigate to no matter what other page, I'll get the error: "The provider requires session state to be enabled". I'm sure that I have session state enabled because I use it myself.
Is anyone experiencing the same issue and found a solution for this?
Bart
session state
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: The provider requires SessionState to be enabled
Jul 24, 2008 09:27 AM|LINK
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
Mike343
Member
149 Points
45 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 02:04 AM|LINK
I am running into this same problem as well but I am using windsor to resolve my controllers. I do not have the session state disabled as well. I even tried adding <sessionState mode="InProc" /> in my web.config with no results either.
basically if I add this
protected override IController GetControllerInstance(Type type) { return ContainerHelper.Resolve(type).As(); }Haacked
Contributor
6901 Points
412 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 04:37 AM|LINK
Try changing that code to this:
protected override IController GetControllerInstance(Type type) { var controller = ContainerHelper.Resolve(type).As(); return controller; }And put a break point on the line with "return controller" and check to see if controller.TempDataProvider is an instance of SessionStateTempDataProvider. If it's not, then perhaps Windsor is setting it to something else.Senior Program Manager, Microsoft
What wouldn’t you do for a Klondike bar?
Mike343
Member
149 Points
45 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 05:16 AM|LINK
ya it looks like you might be right, very odd though as windsor didn't do this with preview 3.
Haacked
Contributor
6901 Points
412 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 05:31 AM|LINK
Well TempDataProvider is a new property of Controller in Preview 4. You probably just need to configure Windsor to supply SessionStateTempDataProvider when a dependency for ITempDataProvider is needed.
Senior Program Manager, Microsoft
What wouldn’t you do for a Klondike bar?
Mike343
Member
149 Points
45 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 05:44 AM|LINK
well actually it is failing at this line in SessionStateTempDataProvider.LoadTempData() so it is using the SessionStateTempDataProvider class
if (_httpContext.Session == null) {
throw new InvalidOperationException(MvcResources.SessionStateTempDataProvider_SessionStateDisabled);
}
seems the session is null.
[InvalidOperationException: The provider requires SessionState to be enabled.]
System.Web.Mvc.SessionStateTempDataProvider.LoadTempData() +150
System.Web.Mvc.TempDataDictionary.Load(ITempDataProvider tempDataProvider) +10
System.Web.Mvc.Controller.Execute(ControllerContext controllerContext) +103
System.Web.Mvc.Controller.System.Web.Mvc.IController.Execute(ControllerContext controllerContext) +4
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +212
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +36
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
Haacked
Contributor
6901 Points
412 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 05:52 AM|LINK
Weird, that would happen if session was disabled somehow.
Senior Program Manager, Microsoft
What wouldn’t you do for a Klondike bar?
Mike343
Member
149 Points
45 Posts
Re: The provider requires SessionState to be enabled
Jul 26, 2008 07:49 AM|LINK
I figured it out and it was basically just a configuration problem.
Windsor creates components by default as a singleton, setting the component lifestyle to transient fixes the problem atleast for my case.
Pavel Samokh...
Member
8 Points
6 Posts
Re: The provider requires SessionState to be enabled
Jul 27, 2008 04:29 PM|LINK
I have the same problem (but use Spring.net, and don't want to make my controllers non-singleton):
[InvalidOperationException: The provider requires SessionState to be enabled.] appears on every request, after first.
As you can see from this screenshot, problem is that actual HttpContext and HttpContext, that was set in SessionStateTempDataProvider are different.
So basically it can be solved something like:
But this is nothing more than awful workaround - please investigate why it happens.