简体   繁体   English

对网页上的每个HTML标记使用ASP Web表单控件是否效率低下?

[英]Is it inefficient to use ASP web forms controls for every HTML tag on a web page?

Should I be using tags (or literal tags) for every piece of content on my page (h tags, p tags, etc.)? 我应该为页面上的每个内容使用标签(或文字标签)(h标签,p标签等)吗? Even if it is not dynamic. 即使它不是动态的。 Or is this considered to be inefficient having the server process all this content? 或者,如果服务器处理所有这些内容,这被认为效率低下?

No, you should not use server tags for static content on your page that does not need it. 不,您不应将服务器标签用于页面上不需要它的静态内容。

Every servers-side tag you add to your ASP.Net web page (ie every tag that has a runat="Server" attribute) adds extra processing to your page. 您添加到ASP.Net网页的每个服务器端标记(即每个具有runat =“Server”属性的标记)都会为您的页面添加额外的处理。 For each server tag, ASP.Net adds information to viewstate, which must then be serialized and sent across the wire for each request. 对于每个服务器标签,ASP.Net将信息添加到viewstate,然后必须将其序列化并通过线路发送每个请求。 In addition, when the page is processed and rendered on the server, the ASP.Net pipeline must instantiate these server-side tags and re-hydrate their properties from viewstate. 此外,当在服务器上处理和呈现页面时,ASP.Net管道必须实例化这些服务器端标记并从viewstate重新保持其属性。 All of this adds overhead to a request processing. 所有这些都增加了请求处理的开销。

So for basic HTML tags that do not require persistance of server-side state or do not require the advanced functionality of ASP.Net web forms or HTML controls, do not use server-side tags. 因此,对于不需要服务器端状态持久性或不需要ASP.Net Web表单或HTML控件的高级功能的基本HTML标记,请不要使用服务器端标记。 Just use the basic HTML tags (ie H1, P, etc) without the runat="server" attribute. 只需使用没有runat =“server”属性的基本HTML标记(即H1,P等)。

For more information on the ASP.Net page lifecycle, see here . 有关ASP.Net页面生命周期的更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以将带有表单控件的SMTP HTML电子邮件发布到网页上? - Is it possible to post an SMTP HTML email with forms controls to a web page? 是否可以在ASP .NET Web表单中使用jQuery UI控件而不是Web控件? - Is it possible to use jquery ui controls instead of web controls in asp .net web forms? ASP.NET web forms HTML 标记中的自定义属性 - Custom attributes in ASP.NET web forms HTML tag 是否可以在ashx页面中使用asp.net Web控件? - Is it possible to use asp.net web controls in ashx page? ASP.NET Web窗体:对来自不同命名空间的Web控件使用相同的tagPrefix - ASP.NET Web Forms: Use same tagPrefix for web controls from different namespaces 使用ASP.NET Web表单中的普通html控件表单发布值 - Form Post Values using plain html controls in ASP.NET web forms 如何在线程(ASP.NET Web窗体)中访问页面控件(标签,计时器等) - How access page controls (label, timer, etc) inside a thread (ASP.NET Web Forms) 在网页(HTML)上具有与Windows窗体等效的丰富窗体控件的最佳机制 - Best mechanism to have rich form controls on web page (HTML) equivalent to windows forms ASP.NET Web窗体 - 模型视图演示者和用户控件 - ASP.NET Web Forms - Model View Presenter and user controls 全局验证ASP.NET Web窗体应用程序中的文本控件 - Global validation of text controls in an ASP.NET web forms application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM