10 Tips to Improve an ASP.NET Applications Performance
2015-06-10 14:26
423 查看
In developing .NET applications, there are a few things that can be done, or avoided, to make significant and noticeable improvements in performance. Here are a few that are worth implementing:
Caching:
If your application is processing quite a bit of information, mostly static, avoid getting that information when it’s not needed. For example, getting certain key values in the web.config file.
Response.Redirect vs. Server.Transfer:
Response.Redirect sends quite a bit of information to the server and should be used when transferring/posting to another physical server. Server.Transfer however, only posts
the form information and not the entire page. It also loads pages faster and should be used for transfers within your server.
Avoid Exceptions?:
As much as they help with catching those elusive bugs, throwing exceptions can add significant overhead to your application. Check for conditions that may cause exceptions before throwing them and use them when absolutely necessary.
Use Page.IsPostBack to minimize processing:
Using Page.IsPostBack can help in reducing the amount of redundant processing and execution of code that’s only needed once, for example, when a page loads.
StringBuilder:
If you’re working with very large strings, use StringBuilder.Append as opposed to string += string (orString.Concat), it’s faster.
Turn Off ViewState:
If you’re not posting back to a form, turn off ViewState as it slows the loading of pages.
Paging:
If you’re going to show dynamically generated data in your application, use the paging capabilities of .net to display small set of data at any given time.
Client-Side vs. Server-Side Validation:
Avoid using server-side validation where it’s not needed and use client-side validation instead.
Use Release Build:
When deploying your application to the production site, make sure to not use the Debug Build as running in debug mode slows your application down.
And finally (not quite):
Utilize the finally block as best you can as it is the only block of code that is guaranteed to be executed. Any open database connections, text readers, files etc. should be closed here to reduce the number of resources left unhandled that
can slow your application down.
These are just a few additions that can help when it comes to improving applications performance. There are many many more out there, but thesesare the ones that we should try to implement on a daily basis when developing applicaitions.
Happy coding!
Caching:
If your application is processing quite a bit of information, mostly static, avoid getting that information when it’s not needed. For example, getting certain key values in the web.config file.
Response.Redirect vs. Server.Transfer:
Response.Redirect sends quite a bit of information to the server and should be used when transferring/posting to another physical server. Server.Transfer however, only posts
the form information and not the entire page. It also loads pages faster and should be used for transfers within your server.
Avoid Exceptions?:
As much as they help with catching those elusive bugs, throwing exceptions can add significant overhead to your application. Check for conditions that may cause exceptions before throwing them and use them when absolutely necessary.
Use Page.IsPostBack to minimize processing:
Using Page.IsPostBack can help in reducing the amount of redundant processing and execution of code that’s only needed once, for example, when a page loads.
StringBuilder:
If you’re working with very large strings, use StringBuilder.Append as opposed to string += string (orString.Concat), it’s faster.
Turn Off ViewState:
If you’re not posting back to a form, turn off ViewState as it slows the loading of pages.
Paging:
If you’re going to show dynamically generated data in your application, use the paging capabilities of .net to display small set of data at any given time.
Client-Side vs. Server-Side Validation:
Avoid using server-side validation where it’s not needed and use client-side validation instead.
Use Release Build:
When deploying your application to the production site, make sure to not use the Debug Build as running in debug mode slows your application down.
And finally (not quite):
Utilize the finally block as best you can as it is the only block of code that is guaranteed to be executed. Any open database connections, text readers, files etc. should be closed here to reduce the number of resources left unhandled that
can slow your application down.
These are just a few additions that can help when it comes to improving applications performance. There are many many more out there, but thesesare the ones that we should try to implement on a daily basis when developing applicaitions.
Happy coding!
相关文章推荐
- 分享微信开发Html5轻游戏中的几个坑
- 星外ASP.Net的安全设置相关说明
- C#、ASP.NET通用扩展工具类之TypeParse
- C#、ASP.NET通用扩展工具类之LogicSugar
- C#、ASP.NET通用工具类IsWhat?(可以判断数字、身份证、数据类型等等)
- 程序中常用的种代码
- ASP.NET、ASP、PHP、JSP之间有什么区别?
- ASP.NET页面间的传值的几种方法
- 入侵ASP.net网站的经验附利用代码
- asp.net OleDbCommand 的用法
- jquery调用asp.net 页面后台的实现代码
- asp.net中的check与uncheck关键字用法解析
- ASP.NET MVC 4 捆绑和缩小实例介绍
- ASP.Net Post方式获取数据流的一种简单写法
- asp.net动态产生checkbox(数据源为DB或内存集合)
- Asp.Net 和 AJAX.Net 的区别第1/2页
- asp.net利用后台实现直接生成html分页的方法
- asp.net用三层实现多条件检索示例
- ASP.NET Cookie 操作实现
- asp.net SqlDataAdapter对象使用札记