Posted By : Shailendra Chauhan, 06 Jan 2013

Updated On : 11 Jun 2014

By default, Asp.Net MVC support session state. Session is used to store data values across requests. Whether you store some data values with in the session or not Asp.Net MVC must manage the session state for all the controllers in your application that is time consuming. Since, session is stored on server side and consumes server memory, hence it also affect your application performance.

Session Less Controller

If some of the controllers of your Asp.Net MVC application are not using session state features, you can disable session for those controller and can gain slight performance improvement of your application. You can simplify session state for your application by using available options for session state.

In Asp.Net MVC4, SessionState attribute provides you more control over the behavior of session-state by specifying the value of SessionStateBehavior enumeration as shown below:

SessionStateBehavior Enumeration's Value
Value
Description
Default
The default Asp.Net behavior is used to determine the session state behavior.
Disabled
Session state is disabled entirely.
ReadOnly
Read-only session state behavior is enabled.
Required
Full read-write session state behavior is enabled.

In Asp.Net MVC, TempData use session state for storing the data values across requests. Hence, when you will disabled the session state for the controller, it will throw the exception as shown below:

What do you think?

I hope you will enjoy the tips while programming with Asp.Net MVC. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

最新文章

  1. TNS-12535: TNS:operation timed out案例解析
  2. handler内存泄露
  3. HTTP 错误 500.21 - Internal Server Error
  4. jQuery实现滚动效果详解1
  5. zk框架销毁Page上的Component
  6. users
  7. 【笨嘴拙舌WINDOWS】字符类型与字符串
  8. Java学习第四篇:数组,排序,查找
  9. Entity Framework: Get mapped table name from an entity
  10. Bolt 动画
  11. IOS开发-表视图LV3导航控制器
  12. .bind.apply() 解决 new 操作符不能用与 apply 或 call 同时使用
  13. Spring3 MVC DispatcherServlet 配置问题
  14. &和&&的共同点和区别、Java字符含义和Java创建对象的几种方式
  15. 限制标题字符串的长度,超过长度的截取并加上"..."
  16. CentOS 7下设置Docker代理(Linux下Systemd服务的环境变量配置)
  17. Communications link failure due to underlying exception异常处理(转)
  18. 苹果笔记本 如何配置成php开发系统
  19. python之virtualenv
  20. 三星打印机SCX-4824HN全套驱动(打印/扫描)

热门文章

  1. ubantu 虚拟机无法查看windows共享目录
  2. MySQL插入中文时出现ERROR 1406 (22001): Data too long for column 'name' at row 1 (转)
  3. 平均分割list
  4. 使用nagios插件 check_mysql_health 过程中遇到的error
  5. windows抓包工具Wireshark(过滤)
  6. Vue.js:条件与循环
  7. TIMEQUEST学习之黑金动力(三)
  8. powerdesigner Oracle.sql转mysql.sql
  9. RAD 10 新控件 TSearchBox TSplitView
  10. Spring Cloud Eureka 5 (服务发现与消费-简单的robbin使用)