<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>HttpHandlers and HttpModules</title><link>http://forums.asp.net/27.aspx</link><description>Extending the ASP.NET Framework through HttpModules and HttpHandlers.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Rewriting the URL using IHttpHandlerFactory</title><link>http://forums.asp.net/thread/3263024.aspx</link><pubDate>Mon, 29 Jun 2009 01:11:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3263024</guid><dc:creator>mcleanap</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3263024.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3263024</wfw:commentRss><description>&lt;p&gt;I am using the following post (http://www.uberasp.net/getarticle.aspx?id=49) to process url rewrites on our website.&amp;nbsp; I am fairly new to .NET development, so I was curious if this is a good way to do the URL rewrite.&amp;nbsp; &lt;/p&gt;&lt;p&gt;1. Would there be any issues with post back?&amp;nbsp; I don&amp;#39;t see that there are.&lt;/p&gt;&lt;p&gt;2. Would these URLs be properly indexed by search engines?&lt;/p&gt;&lt;p&gt;3. Any other issues that I should be aware of?&lt;/p&gt;&lt;p&gt;I have modified the code somewhat to hopefully fit my needs.&amp;nbsp; Do you see any issues with it?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In the web.config file, I changed it to look for any file in the root with an aspx extension.&lt;/p&gt;&lt;p&gt;&amp;lt;add verb=&amp;quot;*&amp;quot; path=&amp;quot;*.aspx&amp;quot; type=&amp;quot;MyPageFactory&amp;quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;In the MyPageFactory class, I fill a list of pages that I wouldn&amp;#39;t want the URL rewrite to apply to.&lt;/p&gt;&lt;p&gt;&lt;pre name="code" class="c-sharp"&gt;using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using System.Web.UI;

public class MyPageFactory : IHttpHandlerFactory
{
    public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
    {
        string pageName = &amp;quot;~/Default.aspx&amp;quot;;

        List&amp;lt;string&amp;gt; pageList = new List&amp;lt;string&amp;gt;();

        pageList.Add(&amp;quot;contact&amp;quot;);
        pageList.Add(&amp;quot;login&amp;quot;);
        pageList.Add(&amp;quot;forgotpassword&amp;quot;);

        context.Items[&amp;quot;fileName&amp;quot;] = Path.GetFileNameWithoutExtension(url).ToLower();
        string fileName = context.Items[&amp;quot;fileName&amp;quot;].ToString();

        if (pageList.Exists(delegate(string s) { return s == fileName; }))
        {
            pageName = &amp;quot;~/&amp;quot; + fileName + &amp;quot;.aspx&amp;quot;;
        }
        else
        {
            pageName = &amp;quot;~/Default.aspx&amp;quot;;
        }

        return PageParser.GetCompiledPageInstance(url, context.Server.MapPath(pageName), context);
    }

    public void ReleaseHandler(IHttpHandler handler)
    {

    }
}


&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>