(2)Remove unused View Engines 招数2: 移除不用的视图引擎 If you're an ASP.NET MVC developer, you might not know that ASP.NET still loads the View Engines for both Razor and Web Forms by default. This can cause performance issues because MVC will normally look fo…
Database Performance Tips for Developers对于开发人员的数据库性能技巧 As a developer you may or may not need to go into the database and write queries or design tables and indexes, or help determine configuration of your SQL Server systems. But if you do, these tip…
(27)Throw hardware at the problem, not developers 招数27: 把问题仍给硬件而不是开发人员 As developers, we often want to fix problems with code, but don’t be afraid to ‘put the compiler down’ and throw some hardware at the problem.作为开发人员,我们通常想通过代码解决问题,但不要害怕‘批评编译器’和把问题…
(17)Avoid running sites in debug mode 招数17: 避免在调试模式下运行网站 When it comes to ASP.NET, one of the most common performance blunders I see on a regular basis is accidentally or intentionally running sites in debug mode. Language-level optimizations, such a…
(13)Always perform validation on the server as well 招数13: 总是在服务器端执行验证 This isn’t exactly a performance tip but rather a security tip for when people think that they could improve performance by cutting out server-side validation. These days, client-s…
ORM TipsORM小窍门 More and more people are using Object to Relational Mapping (ORM) tools to jump the divide between application code that is object oriented and a database that is storing information in a relational manner. These tools are excellent an…
(39)Avoid using session state 招数39: 避免使用会话状态 Where possible, you should try and avoid using session state. Whilst using one web server, performance is usually not a problem. This changes as soon as you need to scale to multiple servers, as different,…
(32)Seven handy ViewState tips 招数32: 7条便利的ViewState技巧 Every time I have to deal with a classic ASP.NET Web Forms application, one of the first things I look at is the resulting source, to check whether the DOM is a complete mess and whether the ViewS…
(30)Static collections 招数30: 静态集合 If a collection is static, make sure it only contains the objects you need. If the collection is iterated over often, then the performance can be slow if you don’t remove unnecessary objects. Objects in a collection…
(29)Before tackling any website performance issue, first verify the problem isn’t on the client 招数29: 在处理网站性能问题前,首先验证问题是否出在客户端 Traditionally, many performance problems have been rooted in either the database or application server. 习惯上,许多性能问题要么根植于数据库或…
(28)Don’t assume that problems can only arise from business logic 招数28: 不要认为问题只会从业务层产生 When beginning to diagnose performance problems, we often assume the problem is in our business logic. Don’t forget that the areas of our code that provide infrast…
(26)Don’t underestimate the value of the UI when tackling performance problems 招数26: 解决性能问题时不要低估UI的价值 Simple UI tricks, such as progress bars, redirecting users’ attention using animation, or placing slower loading sections at the bottom of a page or…
(25)Use the startMode attribute to reduce the load time for your ASP.NET site 招数25: 使用startMode属性来减少ASP.NET站点加载时间 Every time you update your site, IIS must recompile it during the first request, so the initial request takes significantly longer than…
(16)Reduce the data sent across the network 招数16: 减少通过网络发送的数据 Reducing the amount of data sent across the network can improve application performance significantly. Compressing CSS and JavaScript is possible using bundling and minification. This will…
(14)Review what client scripts you are using 招数14: 检查你使用了什么客户端脚本 Out of the box, many ASP.NET projects include client script libraries which you may or may not beusing. It’s always a good idea to check what you are using, and when.拿来即用,很多ASP.NET项目包括你…
(11)Make sure paging is conducted at the database layer 招数11: 确保分页是在数据层完成的 When using grid UI controls (framework based, or 3rd party owned), you should carefully consider how paging is implemented. Many controls implement paging in a simplistic fash…
(4)A selection of tips 招数4: 精选的技巧 Make sure HTTP compression is turned on for any uncompressed content. HTML in particular compresses significantly, and in this era of mobile friendliness and slow 3G connections, that’s essential.确保为未压缩的内容打开HTTP压缩.在这…
(1)Caching is a last resort 招数1: 缓存是最后的手段 Projects that use multiple levels of cache often demonstrate a misunderstanding of why caching is required in the first place. 项目中使用多重缓存经常会表现会产生误会,为什么缓存是第一步必须的. Caching is not synonymous with performance. You…
(41)StringBuilder is NOT the answer for all string concatenation scenarios; String.Join could be 招数41: StringBuilder不适用于所有字符串连接的场景:String.Join可能是 Yes, if you are in a loop and adding to a string, then a StringBuilder *could* be most appropriate. Howe…
(40)Take advantage of .NET 4.5 async constructs 招数40: 利用.NET 4.5异步结构 With the arrival of .NET 4.5, writing async code correctly is easier than ever. Like any tool, it should be only applied where it makes most sense – in web use-cases this usually re…
(31)Know your loops 招数31: 认识你的循环 for is the fastest way of iterating over a collection, foreach is a little slower, and LINQ queries are slowest.for是遍历集合最快的方法,foreach略慢一些,LINQ查询最慢. 测试代码: using System; using System.Collections.Generic; using System.Li…
(19)A selection of tips 招数19: 精选技巧集合 Including height and width in <img /> tags will allow your page to render more quickly, because space can be allocated for the image before it is downloaded.在<img />标签中包括height和width属性会加速你的页面呈现,因为下载完成之前空间可以…
(18)When in production, carefully consider what you need to log 招数18: 在生产环境,仔细考虑你需要记录哪些日志 Many people deploy to production without checking how logging is currently configured. It is always advisable to check whether your policy is to have logging on…
(15)Reduce memory leaks dramatically with the “using” statement 招数15: 显式的使用using语句减少内存泄露 If a type implements IDisposable, wrap the use of it in a “using” statement, so that it automatically disposes of objects properly when the block exits.如果一个类实现了I…
(12)For a snappy user experience, always validate on the client 招数12: 为了生动的用户体验,总是在客户端验证 To avoid unnecessary round trips to the server, validate form entries on the client using JavaScript before posting them. This provides quick feedback and makes…
(3)Use Microsoft’s PDBs to debug or profile external assemblies or libraries 招数3: 使用Microsoft的PDBs调试和分析外部的程序集和库 To accurately debug or profile an external assembly or library (i.e. one you’re not directly compiling), you need the PDB files that accom…
Asp.net MVC 默认提供两个视图引擎,分别为: WebFormViewEngine 和 RazorViewEngine.MVC在查找视图时,会按照指定的顺序进行查找.当我们的MVC程序未找到相应视图时,页面中将出现如下错误信息: 由上图可知,它优先执行的是 webform 视图引擎查找,其次才是 razor 视图引擎.而在我们mvc项目中,通常只用到 razor 或 webform 中的一种(大多数都是用的razor).假如我们项目中只用到 razor ,那么在这种情况下,去执行 web…
Razor简介 Razor是ASP.NET新增的一个视图引擎,由微软全球最年轻的副总裁,有着"ASP.NET之父"称呼的Scott Guthrie主导的团队开发. 主导Razor开发的Scott Guthrie,毕业于美国杜克大学.现任微软云计算与企业级产品工程部执行副总裁. Razor对传统aspx页面的写法和页面渲染能力提出了反思,所以它在代码书写和HTML生成方面都进行了优化.Rzaor的设计目标遵循以下几点: a). 尽量减少代码 b). 上手快,只需要现有的编程语言和基本的H…
之前体验过razor视图引擎@符号的威力了吧~ 连我这个初学者都能感觉到确实省时省力方便快捷 简直就是居家旅行*人*货必备之物啊(这里和谐两个字~) 那么现在就开始对razor的语法进一步介绍~ 1.C#语句块 这个就不用说了吧~ @{代码} 大括号之间写C#代码 关键是还能在C#代码之间直接穿插html标签 这是razor的一大特点 但是它是怎么识别的呢 是根据html标签? 还是<尖括号? 我们可以来做个小测试 在Home控制器中添加一个名为RazorTest的action方法,并添加视图(…
[编者按]本文出自站外作者 Brij Bhushan Mishra ,Brij 是微软 MVP-ASP.NET/IIS.C# Corner MVP.CodeProject Insider,前 CodeProject MVP,CodeProject Mentor 以及 CodeProject Platinum Member,拥有6年左右的高级开发工程师/架构师经验,自幼酷爱计算机. 采用 ASP.NET 和 IIS 构建 Web 应用程序并将其托管到 Web 服务器上极其简单,但是许多可提升 We…