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.
The ASP engine ignores the HTML code blocks.
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.
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.
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.
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>
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:
These things may change over time:
If the urls are private, it doesn't really matter how you construct them, as long as it helps your application.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With