URL- / - .
The following is a stripped-down version of URL rewriting in IIS 6.
Here is a very simple version of URL rewriting that you can put in your Global.asax or Global.asax.cs file at the root of your site.
This piece of code. Redirects the URL / Store / Categories / to / Store / Default.aspx? Action = categories, while the user sees / Saves / Categories / in his URL, your application sees the URL as /Default.aspx? action = categories and Request ["action"]. ToString () will have a value of "categories"
void Application_BeginRequest(object sender, EventArgs e)
{
string fullOriginalpath = Request.Url.ToString().ToLower();
if (fullOriginalpath.Contains("/store/categories/"))
{
Context.RewritePath("/Store/Default.aspx?action=categories");
}
else if (fullOriginalpath.Contains("/store/products/"))
{
Context.RewritePath("/Store/Default.aspx?action=products");
}
}
source
share