Reputation: 2140
I am creating a website in .aspx, and while adding more pages I saw that I can choose for an .aspx-extension and for a .html-extension.
I am a bit confused at the moment. Normally I am using always the .aspx one, but what is the difference between them and which of them do you guys prefer me to use?
Thank you very much.
Upvotes: 0
Views: 1962
Reputation: 45083
.htm/l files are generally used for static markup, but they can be .NET-enabled also (using configuration options). That is to say, other extensions can be compiled and run through the ASP.NET ISAPI handler to be pages that have code-behind and managed controls and "do stuff" server-side.
I guess it's preference, so you could decide to use .htm/l for server-handled pages and .aspx for handled pages. I personally don't find this option appealing and have to deal with, at least weekly, an .htm/l page that didn't need any .NET stuff but now does. It doesn't make sense to me to mix up the files like this - the effort for IIS should be negligible, particularly for .aspx pages that contain only static content. It's much less effort than having to wonder about changing file names (and therefore URLs or rewrites) or setting global configuration options to handle certain extensions because modifications were needed.
Upvotes: 1
Reputation: 553
This is the biggest challenge for the beginners. Aspx pages and asp.net webservercontrols
are like machines that spit out html. if you want a logic to spit html on the page according to that logic then use .aspx
or Webservercontrols
on that page. if you don't have very serious decisions to make programmatically and need straight forward html that does not change based on some events then use .html
pages. But if you are on something like asp.net then it means you may have to make decisions based on data from the server so in that case .aspx
would be requirement than an option.
Upvotes: 3
Reputation: 8043
An HTML file can only contain static content (it can not contain any server side code), it will not be processed by the ASP.NET pipeline.
So normally you should always use aspx files in an ASP.NET app, except if you have a page which only has to contain static HTML, that way you might save some performance, because IIS can directly serve that file without running it through the whole pipeline.
Upvotes: 1