I Need your Help Please; I'm developing a asp.net web application using c# I used Microsoft AspNet FriendlyUrls to make url without the suffix aspx in App_Code>App_start I added the following class
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings,new WebMethodFriendlyUrlResolver());
}
public class WebMethodFriendlyUrlResolver : WebFormsFriendlyUrlResolver
{
public override string ConvertToFriendlyUrl(string path)
{
if (HttpContext.Current.Request.PathInfo != string.Empty)
{
return path;
}
else
{
return base.ConvertToFriendlyUrl(path);
}
}
}
}
in Global.asax i used the following code
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteConfig.RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}
it's working fine for dropping aspx part from url NOW.......... I have a search page uses 3 parameters in url , as a example (Plumber,Cairo,Dar Elsalam)
.../search/find?Syx=job=Plumber%20+%20state=CAIRO%20+%20city=ELSALAM%20DAR%20+%20
How to make Up URL become
.../search/plumber-in-dar-elsalam
I Would be appreciated to Your ideas
i searched over internet for a solution but couldn't find a suitable solution to my case
I tried this code
routes.MapPageRoute("plum-darelsalam", "plumber-in-dar-elsalam", "~/find?Syx=job=Plumber%20+%20state=CAIRO%20+%20city=ELSALAM%20DAR%20+%20.aspx");
after
routes.EnableFriendlyUrls(settings,new WebMethodFriendlyUrlResolver());
But didn’t work ☹️