locked
Request: How to HttpHandlers aspx to html page RRS feed

  • Question

  • User1282751265 posted

    I want change extend on Asp.net page is ".aspx" to extend ".html" using HttpHandlers

    Anyone, Help me please!

    Thanks advanced 

    Wednesday, February 7, 2007 2:40 AM

Answers

  • User-1069184416 posted

    This is called URL Rewriting! Check out this document if you are using ASP.NET 1.1: URL Rewriting in ASP.NET

    Hope this helps,

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 7, 2007 6:22 AM
  • User113421904 posted

    Alternatively, you can map .html and .htm extensions to Asp.net page handler, then all of the static html & htm page will handled by Asp.net.

    You need to configure your extension both in IIS & Asp.net configuration file.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 8, 2007 4:38 AM
  • User113421904 posted

    Hi,

    First, in IIS Manager, go to web site Properties, Home Directory, Configuration..., Mappings

    Map .htm extenstion to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll, (here I'm using asp.net 1.1)

     

    Second, add httphandler in your web.config like this:


            <httpHandlers>
                <add path="*.htm" verb="*" type="System.Web.UI.PageHandlerFactory"
                    validate="true" />
            </httpHandlers>

     

    Third, create a sample .htm, e.g. sample.htm under your web application.

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

    <!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>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
       
        <% Response.Write("hello world"); %>
        </div>
        </form>
    </body>
    </html>

    You can find it is actually parsed by asp.net.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 9, 2007 6:32 AM
  • User-535404256 posted

    Hello,

    The problem solved. I just need to add runat="server" attribute to all my images and it worked for me.

    adding  runat="server" is an overhead for my server ??

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 14, 2007 9:30 AM

All replies

  • User-1069184416 posted

    Your question is not clear! I can help you with HttpHandlers, but state clearly what you want to do? extend ".aspx" to ".html"? what does that mean?

    Regards

    Wednesday, February 7, 2007 2:55 AM
  • User1282751265 posted

    example:
    My page: http://www.example.com/NewsDetails.aspx?NewsID=1000
    I has been handler it to http://www.example.com/ShowNews/1000/test-the-news.aspx

    now i want hander to http://www.example.com/ShowNews/1000/test-the-news.html

    Can you help me?
    Thanks advanced
     

    Wednesday, February 7, 2007 4:16 AM
  • User-1069184416 posted

    This is called URL Rewriting! Check out this document if you are using ASP.NET 1.1: URL Rewriting in ASP.NET

    Hope this helps,

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 7, 2007 6:22 AM
  • User113421904 posted

    Alternatively, you can map .html and .htm extensions to Asp.net page handler, then all of the static html & htm page will handled by Asp.net.

    You need to configure your extension both in IIS & Asp.net configuration file.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 8, 2007 4:38 AM
  • User1282751265 posted

    Thank you reply.

    Can you give me a demo of that?

     

    Friday, February 9, 2007 1:59 AM
  • User113421904 posted

    Hi,

    First, in IIS Manager, go to web site Properties, Home Directory, Configuration..., Mappings

    Map .htm extenstion to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll, (here I'm using asp.net 1.1)

     

    Second, add httphandler in your web.config like this:


            <httpHandlers>
                <add path="*.htm" verb="*" type="System.Web.UI.PageHandlerFactory"
                    validate="true" />
            </httpHandlers>

     

    Third, create a sample .htm, e.g. sample.htm under your web application.

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

    <!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>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
       
        <% Response.Write("hello world"); %>
        </div>
        </form>
    </body>
    </html>

    You can find it is actually parsed by asp.net.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 9, 2007 6:32 AM
  • User1282751265 posted
    Thanks advanced
    Friday, February 9, 2007 11:41 PM
  • User-535404256 posted

    Hello,

    I am doing same. its a URL rewriting.

    for request

    /product/1234/abc.html

    I am redirecting that to

    /productdetails.aspx?id=1234.

    Page is working fine but images are not coming there as, I am setting image source in page as "~/image/picture.jpg" . this intsructs IIS to pick the picture from site root.

    but when page is rendered the image src becomes  "/product/1234/~/image/picture.jpg".

    even when I a, keeping the image folder at the same level of page and set image src to   "image/picture.jpg", it is finally rendering as "/product/1234/image/picture.jpg".

    What is I am missing there  

    Thanks !!! 

    Saturday, February 10, 2007 1:54 AM
  • User-535404256 posted

    Hello,

    The problem solved. I just need to add runat="server" attribute to all my images and it worked for me.

    adding  runat="server" is an overhead for my server ??

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 14, 2007 9:30 AM