Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do some people turn their asp.net pages into HTML pages when published?

I was just told that I might have to work on a project where i will be working with ASP.NET 3.5 and C#. Someone in our team said that we should change all the pages to HTML when we publish the site. So instead of having www.test.com/Page.aspx we will have www.test.com/Page.html

So what i would like to know is:

A.) How can this be done and with what tool?

B.) Why should this be done and what can we benefit from it? (Was told to prevent hackers to get it)

C.) Is this recommended?

Thanks in advance.

like image 483
Etienne Avatar asked Jul 10 '09 08:07

Etienne


People also ask

Can HTML code be used in ASP pages?

The ASP engine ignores the HTML code blocks.

Is asp net a HTML?

ASP is a server-side language. This means that the code that is written gets sent to the server, and it returns some code depending on what it was asked to do. HTML is a client-side language. Basically it has to do with the user interface, with which the user interacts.

What is HTML razor?

Razor is a markup syntax for embedding . NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.


3 Answers

A) You do it by changing Web.config:

<system.web>
    <httpHandlers>
        <add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory"/>
    </httpHandlers>
</system.web>

B) The reason would be to prevent viewers from knowing what runtime is behind the site, but in most cases with ASP.NET, it's easy to recognize from its additions to the HTML (such as view state etc.)

C) It's up to you really, I wouldn't say it's good or bad.


In response to your comment below:

It's possible that you need to specify a buildHandler as well:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true">
      <buildProviders>
        <add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
      </buildProviders>
    </compilation>
    <httpHandlers>
      <add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" />
    </httpHandlers>
  </system.web>
</configuration>
like image 199
Blixt Avatar answered Oct 15 '22 23:10

Blixt


B) C)

If the urls are public, you should put in url's relevant information, and things that are unlikely to change in the next 10-20 years (or more..), and that would be:

  • a short description about the presented page

These things may change over time:

  • ids - if you port the data to other systems
  • .html .php .jsp .do .aspx if you change the technology
  • /controller/view/main if you rearrange the structure of your site

If the urls are private, it doesn't really matter how you construct them, as long as it helps your application.

like image 27
Mercer Traieste Avatar answered Oct 15 '22 23:10

Mercer Traieste


I was a contractor on a large motoring site, and we were asked to not dislpay any file extensions at all, because the company (a very very large news agency) didnt want to appear to pick one technology above another to its investors and suppliers - it was purely a business desicsion, not a techincal or a security by obscurity attempt.

like image 34
Surgical Coder Avatar answered Oct 15 '22 23:10

Surgical Coder