Request: How to HttpHandlers aspx to html page

Last post 02-14-2007 9:30 AM by ShailAtlas. 9 replies.

Sort Posts:

  • Request: How to HttpHandlers aspx to html page

    02-07-2007, 2:40 AM
    • Member
      92 point Member
    • thanhh83
    • Member since 06-13-2005, 8:53 AM
    • Posts 23

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

    Anyone, Help me please!

    Thanks advanced 

    Free Software and Downloadhttp://soft-vn.net. Render by ASP.NET 2.0.


    Dev Application Using .NEThttp://www.devnetapp.com
  • Re: Request: How to HttpHandlers aspx to html page

    02-07-2007, 2:55 AM
    • All-Star
      45,563 point All-Star
    • haidar_bilal
    • Member since 07-14-2003, 1:43 AM
    • Lebanon - Beirut
    • Posts 8,726
    • TrustedFriends-MVPs

    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

    Bilal Hadiar, MCP, MCTS, MCPD, MCT
    Microsoft MVP - Telerik MVP
  • Re: Request: How to HttpHandlers aspx to html page

    02-07-2007, 4:16 AM
    • Member
      92 point Member
    • thanhh83
    • Member since 06-13-2005, 8:53 AM
    • Posts 23

    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
     

    Free Software and Downloadhttp://soft-vn.net. Render by ASP.NET 2.0.


    Dev Application Using .NEThttp://www.devnetapp.com
  • Re: Request: How to HttpHandlers aspx to html page

    02-07-2007, 6:22 AM
    Answer
    • All-Star
      45,563 point All-Star
    • haidar_bilal
    • Member since 07-14-2003, 1:43 AM
    • Lebanon - Beirut
    • Posts 8,726
    • TrustedFriends-MVPs

    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

    Bilal Hadiar, MCP, MCTS, MCPD, MCT
    Microsoft MVP - Telerik MVP
  • Re: Request: How to HttpHandlers aspx to html page

    02-08-2007, 4:38 AM
    Answer

    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.

     

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • Re: Request: How to HttpHandlers aspx to html page

    02-09-2007, 1:59 AM
    • Member
      92 point Member
    • thanhh83
    • Member since 06-13-2005, 8:53 AM
    • Posts 23

    Thank you reply.

    Can you give me a demo of that?

     

    Free Software and Downloadhttp://soft-vn.net. Render by ASP.NET 2.0.


    Dev Application Using .NEThttp://www.devnetapp.com
  • Re: Request: How to HttpHandlers aspx to html page

    02-09-2007, 6:32 AM
    Answer

    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.

     

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • Re: Request: How to HttpHandlers aspx to html page

    02-09-2007, 11:41 PM
    • Member
      92 point Member
    • thanhh83
    • Member since 06-13-2005, 8:53 AM
    • Posts 23
    Thanks advanced
    Free Software and Downloadhttp://soft-vn.net. Render by ASP.NET 2.0.


    Dev Application Using .NEThttp://www.devnetapp.com
  • Re: Request: How to HttpHandlers aspx to html page

    02-10-2007, 1:54 AM
    • Contributor
      2,247 point Contributor
    • ShailAtlas
    • Member since 07-18-2006, 1:07 PM
    • Norway
    • Posts 546

    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 !!! 

  • Re: Request: How to HttpHandlers aspx to html page

    02-14-2007, 9:30 AM
    Answer
    • Contributor
      2,247 point Contributor
    • ShailAtlas
    • Member since 07-18-2006, 1:07 PM
    • Norway
    • Posts 546

    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 ??

Page 1 of 1 (10 items)