« Previous Next »

Thread: Run HTML pages as >net in IIS 7.0

Last post 11-19-2009 2:31 PM by CarlosAg. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 06-12-2009, 3:29 PM

    Run HTML pages as >net in IIS 7.0

     Hi

    We are running some HTML files as ASP.net file  with aspnet_Isapi handler in IIS 7.0 in windows 2008. These files are loading, but are loading the .Net script on the top
    <%@ Page Language="C#" %>  

    Here is the sample file in .html file

    <%@ Page Language="C#" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Test</title>
    </head>
    <body>
        <form id="form1" runat="server" method="Post">
        <div>
            comming soon..
            HTML to ASPX
         </div>
        </form>

    </body>
    </html>


    Please let us know how we can run HTML files as ASP.Net files.( We tried both Classic and Integrated mode). The pages are served well in IIS 6, but its not working on IIS 7.0

    Thanks for your help.

    Harsh.

  • 06-15-2009, 1:11 PM In reply to

    Re: Run HTML pages as >net in IIS 7.0

    First, why are you running HTML files as ASP.NET (I assume by changing the extension ro using wildcard extension mapping)?  In IIS7's Integrated Pipeline, every file runs throiugh the ASP.NET pipeline, regardless of it being HTML or ASP.NET or even a JPG.  This pretty much eliminates any valid reason to run plain HTML with an ASP.NET extension or use wild card mapping of extensions.

    Second, what effect does the @Page directive have on your page?  You should see no difference.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 06-15-2009, 5:46 PM In reply to

    Re: Run HTML pages as >net in IIS 7.0

     hi Jeff,

    We are doing some kind of url rewriting here.. the content of the HTML page is being rendered  with a ASPX page on the fly using the url rewriting, our one of the old server is running on IIS 6 and the new server we have IIS 7.0.

     also because of our URLs are  already listed in most of the Search Engines with good PR, so  we can not change it.. although IIS 7.0 have a very good url Rewritter extension.

    so we are using our custom url rewritter module.

    this is the only reason we want to execute our .html pages as ASPX.

     

    Thank you,

    Satyadev Singh 

     

     

     

     

     

     

     

     

     

  • 06-15-2009, 5:50 PM In reply to

    Re: Run HTML pages as >net in IIS 7.0

     if you execute this code as a ASPX you will see only

    comming soon..
     HTML to ASPX

     

    on client side .. and if the page is executed as HTML .. will see 

     

    <%@ Page Language="C#" %>  

    comming soon..
     HTML to ASPX

     

    ** This is just a test page for testing.. nothing to do with our main apps.

     

    Thank you,

    Satyadev

     

     

     

     

     

     

  • 11-18-2009, 8:26 PM In reply to

    • varmar
    • Not Ranked
    • Joined on 11-19-2009, 1:22 AM
    • Posts 1

    Re: Run HTML pages as >net in IIS 7.0

    Hi soodharsh75. did you get the solution for this issue. if yes, please post it. thanks.

  • 11-19-2009, 2:31 PM In reply to

    Re: Run HTML pages as >net in IIS 7.0

    A couple of comments before posting the solution, I would consider using instead URL Rewrite for this, that way you can continue to name your pages .ASPX physically and just rewrite the URLs from HTML to be ASPX, this way editors, etc, just work as expected.

    Now, to map a different extension I wrote a blog on how to do it, but I figure I would post the entire solution here while explaining the different pieces.

    1) The solution depends if your apppool is running Integrated mode or classic. For integrated you do it by adding a handler in the system.webServer/handlers section, for classic you need to add the same aspnet_isapifilter as before but also need to add in system.web/httpHandlers. With both you need to add a compilation build provider so that asp.net understands them. So here it is the web.config that you can drop in the same directory as your application to make it work.

     

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      
    <system.webServer>
        
    <handlers>
          
    <add name="ASPX-HTML-Integrated" path="*.htm" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" preCondition="integratedMode" />
          <
    add name="ASPX-HTML-2.0-Classic-32bit" path="*.htm" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
        </
    handlers>
      
    </system.webServer>
      
    <system.web>
        
    <compilation>
          
    <buildProviders>
            
    <add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
          </
    buildProviders>
        
    </compilation>
        
    <httpHandlers>
          
    <add path="*.htm" type="System.Web.UI.PageHandlerFactory" verb="*" />
        </
    httpHandlers>
      
    </system.web>
    </configuration>

     

    finally here is the blog that explains more about it and shows command line tool to enable this:

    http://blogs.msdn.com/carlosag/archive/2008/07/04/MappingFileExtensionForAspxPagesInIIS70.aspx

     

Page 1 of 1 (6 items)
Microsoft Communities