Note:This is a simplified version. For more information please see references at the end of this post.
namespace Root.Client.SEOHandler
{
public class SEOModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.AuthorizeRequest += new EventHandler(SEOModuleAuthorizeRequest);
}
void SEOModuleAuthorizeRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
/* note:
we must implement switches collection in CustomConfiguration as a property. See complete description of how to implement a custom configuration section in web.config please see Adding new section to web.config - Microsoft ASP.NET
*/
List
for (int i = 0; i < switches.Count; i++)
{
string lookFor = string.Format("{0}/{1}",app.Context.Request.ApplicationPath,switches[i]);
if(string.Compare(lookFor,app.Request.Path)==0)
app.Context.RewritePath(
string.Format(“{0}/{1}”,"required_page.aspx", app.Context.Request.ApplicationPath);
}
}
}
}
Register assembly in web.config
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
...
<system.web>
...
<httpModules>
<add name="SEOModule" type="Root.Client.SEOHandler.SEOModule" />
...
</httpModules>
...
</system.web>
...
</configuration>
Reference: URL Rewriting in ASP.NET


1 comments:
Pattama coding blog ekak welane??? whats going on man?????
Post a Comment