Building ASP.NET application - Best Practices

前端 未结 7 707
轻奢々
轻奢々 2020-12-22 18:40

We are building an ASP.NET application and would like to follow the best practices. Some of the best practices are:


Server side Code:

  • Use catch
7条回答
  •  太阳男子
    2020-12-22 18:51

    1. Create a base page for all your asp.net pages. This page will derive from System.Web.UI.Page and you may put this in YourApp.Web.UI. Let all your asp.net pages dervice from YourApp.Web.UI.Page class. This can reduce lot of pain.

    2. Use Application_OnError handler to gracefully handle any error or exception. You should log the critical exception and send the details of the exception along with date-time and IP of client to the admin email id. Yes ELMAH is sure way to go.

    3. Use ASP.NET Themes. Many developers don't use it. Do use them - they are a great deal.

    4. Use MembershipProvider and RoleProvider. And Never use inbuilt ProfileProvider - They store everything in plain strings. It will drastically slow-down the performance while performing R/W

    5. Use Firebug for client-side debugging. Try to follow YSlow standards for web-applications. Use YSlow extension for FireBug.

    6. Use jQuery for client-scripting.

    7. Never store User Authentication information in session or don't use sessions to judge if user is logged on. Store only minimum necessary information in sessions.

    8. Have a look at PostSharp. Can improve maintainability of your code and make you more productive.

    9. Never ever Deploy asp.net application under debug configuration on production. Find out here what scottgu has to say about this.

    10. User Web Deployment projects. It can transform web.config sections and replace with production server setings. It will merge all compiled code-behind classes into one single assembly which is a great deal.

    11. Use Cookie-less domains to serve static resources like images, scripts, styles etc. Each client request is sent along with whole bunch of cookies, you don't need cookies while serving pictures or scripts. So host those resources on a cookie-less domain.

    12. Minify scripts, stylesheets and HTML response from the server. Removing unnecessary line-breaks and white-spaces can improve the time-to-load and bandwidth optimization.

提交回复
热议问题