It all started out with an application built by someone in marketing. She came to me and asked if it could be secured with a password. I thought this would be an easy task, but forgot about the simple fact that IIS wouldn’t pass the HTML files through the ISAPI dll.
So here we go. If you want to secure HTML documents you need to go through a number of steps.
- You need to tell IIS how to handle the HTML file. In this case we want to run the HTML file through aspnet_isapi.dll.
- Click on the Directory tab in your ASP.NET application in IIS
- Find the .aspx extension, open it, and copy the executable path
- Cancel out of .aspx extension and click the Add button
- Paste the executable path into this new extension window
- For extension, type in .html or .htm depending on what you are using
- Click on Limit to: and type in GET,HEAD,POST,DEBUG
- Make sure Script engine is checked and that Verify that file exists is NOT
- Now html documents will be mapped through the .NET ISAPI
- This is where it all gets interesting. I had done everything in IIS, but HTML files were not being rendered (it was a blank page). Here’s what I did to alleviate that.
- In the web.config add
<httpHandlers>
<add path="*.html" verb="GET,HEAD,POST,DEBUG"
type="System.Web.UI.PageHandlerFactory" validate="true" />
</httpHandlers>
- And…
<compilation>
<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>
- This is what fixed my issue, and everything is now behaving as expected. How did you resolve it?
Helpful Resource: HOW TO: Migrate an ASP Web Application to ASP.NET While Retaining Existing File Name Extensions
Comments
(18)
Tags:
asp.net
|
Categories:
Setup, Code