bonjour,
l'url de ma page aspx est:
www.website.com/swap.aspx?ID=1
je veux utiliser rewriting url pour l'obtenir comme:
www.website.com/hotel-paris-france.aspx
les mots hotel, paris, france sont dynamic du database.
j'ai ce code, est correct ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void Application_BeginRequest(object sender, EventArgs e)
{
// Get the current path
string CurrentURL_Path = Request.Path.ToLower();
if (CurrentURL_Path.StartsWith("/swap/"))
{
CurrentURL_Path = CurrentURL_Path.Trim('/');
string NewsID = CurrentPath.Substring(CurrentPath.IndexOf('/'));
HttpContext MyContext = HttpContext.Current;
MyContext.RewritePath("/hotel-paris-france.aspx");
}
} |
Partager