You can rewrite/route the URL before it actually hits a page, to do this add your routing code in global.asax's
protected void Application_BeginRequest(object sender, EventArgs e)
event. If you are already on the page (eg Employer_login.aspx) you can use
Response.Redirect("newurl")
To redirect a URL in Application_BeginRequest you can use:
Context.RewritePath("new URL comes here", true);
to send someone to a different URL.
and
Request.Url to check the URL the user entered, get the QueryString, etc.
Here's a simple example that will add .aspx to any URL entered where there is an .aspx file at the location but the URL was specified without it:
(eg user entered yourwebsite/default and you wish to change it to yourwebsite/default.aspx):
var requestedfile = Server.MapPath(Request.Url.AbsolutePath);
var filetype = Path.GetExtension(requestedfile).ToLower();
var incomingparamsdir = incomingparams.Length > 0 ? "?" + incomingparams : "";
if ((filetype == "." || filetype == "") && requestedfile.Length > 0)
{
filetype = ".aspx";
requestedfile = Path.ChangeExtension(requestedfile, ".aspx");
if (File.Exists(requestedfile))
{
Context.RewritePath(Path.ChangeExtension(Request.Url.AbsolutePath, ".aspx") + incomingparamsdir);
return;
}
}
Hope this solves your issue.