(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.作为开发人员,我们通常想通过代码解决问题,但不要害怕‘批评编译器’和把问题…
(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. 习惯上,许多性能问题要么根植于数据库或…
(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…
(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…
(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…
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…
(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…
(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…
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,…
(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…
(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属性会加速你的页面呈现,因为下载完成之前空间可以…
(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…
ADO 简介 在 ASP 中访问数据库使用的 ADO 组件. ADO 是一项微软的技术. ADO 指 ActiveX 数据对象(ActiveX Data Objects). ADO 是微软的 Active-X 组件. ADO 会随 IIS 被自动安装 ADO 是一个访问数据库中数据的编程接口 从 ASP 页面访问数据的方法 创建一个到数据库的 ADO 连接 打开数据库连接 创建 ADO 记录集 从记录集提取您需要的数据 关闭记录集 关闭连接 ADO 数据库连接 在进行数据访问前,我们首先先要建立…
插入记录 INSERT INTO 语句 单条记录插入语法 INSERT INTO target [(field1[, field2[, ...]])] VALUES (value1[, value2[, ...]) target 参数要插入数据的表名:field1.field2 等参数为要插入的表的字段名:value1.value2 等参数为对应插入的字段的值. 微软官方帮助信息 INSERT INTO Statement 注意,字段名和字段值都需要用括号括起来,如果需要向多个字段插入值,那么需…
[编者按]本文出自站外作者 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…
ASP.NET: 一.返回多个数据集 检查你的访问数据库的代码,看是否存在着要返回多次的请求.每次往返降低了你的应用程序的每秒能够响应请求的次数.通过在单个数据库请求中返回多个结果集,可以减少与数据库通信的时间,使你的系统具有扩展性,也可以减少数据库服务器响应请求的工作量. 如果用动态的SQL语句来返回多个数据集,那用存储过程来替代动态的SQL语句会更好些.是否把业务逻辑写到存储过程中,这个有点争议.但是我认为,把业务逻辑写到存储过程里面可以限制返回结果集的大小,减小网络数据的流量,在逻辑层也不…