2

HI i am getting error : "The SessionStateTempDataProvider requires SessionState to be enabled." when i try to handle the error. i got a piece of code from the blog below. http://blogs.microsoft.co.il/blogs/shay/archive/2009/03/06/real-world-error-hadnling-in-asp-net-mvc-rc2.aspx i am not using any session. my session state is set to off in web.config.

and from the below thread The SessionStateTempDataProvider requires SessionState to be enabled i got a solution to set the but its already set as such. how to avoid the error. i dont want to use session.

Community
  • 1
  • 1
nimi
  • 5,359
  • 16
  • 58
  • 90
  • Code. We need to see the code that causes the error. – Çağdaş Tekin Oct 23 '09 at 10:17
  • The code that i am using is from this blog. http://blogs.microsoft.co.il/blogs/shay/archive/2009/03/06/real-world-error-hadnling-in-asp-net-mvc-rc2.aspx – nimi Oct 23 '09 at 10:23
  • The sample project attached to that blog post worked fine for me. Did you change anything with that project? – Çağdaş Tekin Oct 23 '09 at 10:45
  • no.. i didnt download the sample projet in the blog. what i did is that i just copied an paste the contents from the blog. Application_Error method and i have created ErrorController.cs and pasted the respective codes. – nimi Oct 23 '09 at 10:57
  • Possible duplicate: http://stackoverflow.com/questions/884852/how-can-i-disable-session-state-in-asp-net-mvc – Daniel Schaffer Apr 30 '10 at 18:04

2 Answers2

0

my session state is set to off in web.config.

That should be what's causing the problem. Apparently, ASP.NET MVC needs the session state.

Check this question about disabling session state.

Community
  • 1
  • 1
Çağdaş Tekin
  • 16,592
  • 4
  • 49
  • 58
  • sorry for my statement, "my session state is set to off in web.config" i am not setting in my web.config. i tried searching the text, but couldnt find it. – nimi Oct 23 '09 at 11:17
  • @Nimesh, it must have something to do with the SessionState being disabled. Because that's the only way I am able to reproduce the error. Plus, that's what the error message suggests. – Çağdaş Tekin Oct 23 '09 at 11:34
  • yeah i agree to your point. but i am not able to extract that out. is there any other ways to handle errors? – nimi Oct 23 '09 at 11:53
  • Of course. The base controller has a virtual method called `HandleUnknownAction`. You can have your own base controller, derived from the `Controller` class and handle 404 errors there. You can also have your own `HandleError` attribute to hande errors occured on controllers/actions. Example : http://stackoverflow.com/questions/766610/how-to-get-elmah-to-work-with-asp-net-mvc-handleerror-attribute – Çağdaş Tekin Oct 23 '09 at 12:05
0

Check the below code out:

https://github.com/NuGet/NuGetGallery/blob/master/src/NuGetGallery/Infrastructure/CookieTempDataProvider.cs

It acts just like default TempDataProvider but instead it uses cookies. If you are not carrying sensitive data with TempData, it might help.

Seb Nilsson
  • 26,200
  • 30
  • 103
  • 130
tugberk
  • 57,477
  • 67
  • 243
  • 335