RewriteHttpModule
App_Code
public class RewriteHttpModule : IHttpModule { public RewriteHttpModule() { // // TODO: Add constructor logic here // } public void Init(HttpApplication context) { context.BeginRequest += new System.EventHandler(this.context_BeginRequest); } public void Dispose() { } private void context_BeginRequest(object sender, EventArgs e) { HttpRequest request = ((HttpApplication)(sender)).Request; HttpContext context = ((HttpApplication)(sender)).Context; HttpResponse response = ((HttpApplication)(sender)).Response; string applicationPath = request.ApplicationPath; if ((applicationPath == "/")) { applicationPath = String.Empty; } string requestPath = request.Url.AbsolutePath.Substring(applicationPath.Length); if (requestPath.ToLower() == "/testurlrewrite.aspx") { context.RewritePath(applicationPath + "/testurlrewrite"); } else if (requestPath.ToLower() == "/home.aspx") { context.RewritePath(applicationPath + "/home"); } } }
<httpModules <add name="Localization" type="RewriteHttpModule" /> </httpModules>
.aspx
URL
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)