简体   繁体   English

带有asp @page指令及其内容标签的html文件会发生什么情况

[英]What is happening with html file with asp @page directive and content tags within it

With ASP.net I am familiar with creating a master page and then being able to set that master page for a .aspx file. 使用ASP.net,我熟悉创建母版页,然后能够为.aspx文件设置该母版页。

With one of our sites where I work we are given ftp access to edit static html pages. 在我工作的站点之一中,我们被授予ftp访问权限以编辑静态html页面。 Within these html pages are a few asp tags, specifically a page directive with title, language and masterpagefile attributes, and a few content tags with id, contentplaceholderid and runat attributes. 在这些html页面中,有一些asp标记,特别是具有标题,语言和masterpagefile属性的页面指令,以及具有id,contentplaceholderid和runat属性的一些内容标记。

My question is how are they doing this? 我的问题是他们如何做到这一点? If I were to add a master page in visual studio for my own project I am unable to pick a master page for .html files. 如果要在Visual Studio中为自己的项目添加母版页,则无法选择.html文件的母版页。 Are they somehow building/overwriting a .aspx file after upload? 他们在上传后是否以某种方式构建/覆盖.aspx文件? If I go to the website the url will show a .html extension. 如果我访问该网站,则该网址将显示一个.html扩展名。

Within these html pages are a few asp tags, specifically a page directive with title, language and masterpagefile attributes, and a few content tags with id, contentplaceholderid and runat attributes. 在这些html页面中,有一些asp标记,特别是具有标题,语言和masterpagefile属性的页面指令,以及具有id,contentplaceholderid和runat属性的一些内容标记。

Then the host is processing these .html files through the ASP.NET runtime before serving them. 然后,主机将在为ASP.NET运行时处理这些.html文件,然后再.html提供服务。 At a technical level ASP.NET pages don't need to have the .aspx file extension, that's just by convention. 在技​​术层面上,ASP.NET页面不需要具有.aspx文件扩展名,这只是按照惯例。 The web server can be configured to process any files as ASP.NET pages. 可以将Web服务器配置为将任何文件处理为ASP.NET页。

If you look through the configuration of IIS for example (and the specifics of that will vary wildly with IIS versions), you might find something like (and this may be quite dated, I haven't had to look under the hood in IIS for years) a mapping for .aspx files to aspnet_isapi.dll . 例如,如果您查看IIS的配置(并且其具体细节将随IIS版本而有很大不同),您可能会发现类似的内容(并且这可能已经过时了,我不必在IIS中进行深入研究年) .aspx文件到aspnet_isapi.dll的映射。 That same configuration can also be changed to also map .html files to aspnet_isapi.dll , which would process them the same way. 也可以更改相同的配置,以将.html文件也映射到aspnet_isapi.dll ,这将以相同的方式处理它们。

This isn't common practice not only because of convention but also because server-side processing adds overhead and is less performant than serving a static file directly from the web server. 这是不常见的做法,不仅因为约定,而且因为服务器端处理会增加开销,并且比直接从Web服务器提供静态文件来的性能要差。 Since .html files traditionally have static content, it's a lot faster to let IIS serve them directly than to process them through the ASP.NET engine. 由于.html文件传统上具有静态内容,因此让IIS直接为其提供服务比通过ASP.NET引擎对其进行处理要快得多。 It's possible , and the host in question seems to be doing exactly that, it's just uncommon for these reasons. 可能 ,并且所讨论的主机似乎正是在这样做,由于这些原因,这种情况并不常见。

In Visual Studio you can change the settings to serve Dynamic content. 在Visual Studio中,您可以更改设置以提供动态内容。

In Application Designer, you must specify whether an ASP.NET application exposes dynamic or static content. 在应用程序设计器中,您必须指定ASP.NET应用程序公开动态还是静态内容。 Dynamic content specifies that a script processor such as ASP.NET is required to run the application or any Web services associated with the application. 动态内容指定运行该应用程序或与该应用程序关联的任何Web服务都需要脚本处理器(例如ASP.NET)。 Static content specifies that no script processor is required, for example, to run the application or to display HTML. 静态内容指定不需要脚本处理器,例如,运行应用程序或显示HTML。

http://msdn.microsoft.com/en-us/library/ms242474(v=vs.90).aspx http://msdn.microsoft.com/en-us/library/ms242474(v=vs.90).aspx

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM