Wednesday, November 12, 2008

Rewrite url with Masterpage & Intelligencia.UrlRewriter.dll in asp.net 2.0

I did following way to rewrite url with Masterpage & Intelligencia.UrlRewriter.dll asp.net 2.0


1.Copy Intelligencia.UrlRewriter.dll in bin folder


2. Put stylesheet as following:
<link href="style.css" rel="stylesheet" type="text/css" id="style1">
3.in Code behind put following code:
style1.Href = Page.ResolveUrl("~/style.css");

4. Your web.config will look like following

<?xml version="1.0"?>

<configuration>
  <configSections>
    <section name="rewriter" requirePermission="false"  type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
  </configSections>
  <system.web>
    <httpModules>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
      
    </httpModules>
  </system.web>

    <rewriter>
      <rewrite url="~/products/(.+).aspx" to="~/products.aspx?category=$1&amp;prdty=$2" />
      <rewrite url="~/mainsearch/(.+)-(.+).aspx" to="~/mainsearch.aspx?URLID=$1&amp;prdty=$2" />
      <rewrite url="~/Default/(.+)-(.+)-(.+).aspx" to="~/Default.aspx?Pageno=$1&amp;URLID=$2&amp;prdty=$3" />
    </rewriter>

</configuration>

No comments: