|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 id="Head1" runat="server">
<title></title>
<style type="text/css">
body{ font-family: Tahoma; font-size: 12px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
Url Rewriting Sample Website</h1>
<h2>Written by Steve J. Riggall</h2><br />
<br />
This sample web site uses an HTTP handler to rewrite requests for *.html
resources.
<br />
<br />
For this to work in IIS6 you need to add a resource mapping to the website
properties by clicking the "Configuration" button on the "Home Directory" tab
(or "Virtual Directory" tab for an application virtual folder), and adding a
mapping for the *.html to the ASP.NET ISAPI extension. This is usually
located at <strong>C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll</strong> but you
can always find and copy the properties for the *.aspx mapping if you are
unsure. You also need to ensure you un-check the option to make sure the
requested resource exists on the server.<br />
<br />
The rewriting should just work when hosted under IIS7 as the handler mappings
are already present in the web.config file.<br />
<br />
<br />
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/FriendlyPage.ashx">Visit "FriendlyPage.ashx"</asp:HyperLink> (This is a rewritten page. It should work with or without IIS mappings as *.ashx are already mapped to ASP.NET ASAPI)
<br />
<br />
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/UnfriendlyPage.aspx">Visit "UnfriendlyPage.aspx"</asp:HyperLink> (This is the aspx page that the above link is mapped to.)
<br />
<br />
<asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="~/ActualPage.html">Visit "ActualPage.html"</asp:HyperLink> (This is an actual static html page. It should be served correctly.)
</div>
</form>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Steve is an MCP and senior software developer for Hidalgo Limited (http://www.hidalgo.co.uk).