I want to make some friendlyurls in my ASP.Net C# project and I'm trying to do this in global.asax
file and protected void Application_Start(object sender, EventArgs e)
but I am getting error in in browser. it is not working. I am attaching screenshot and pasting code also with this.
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("Dashboard", "{FullName}-{Id}/Dashboard", "~/Dashboard.aspx");
routes.MapPageRoute("Reviews", "{FullName}-{Id}/Reviews", "~/Reviews.aspx");
routes.MapPageRoute("Events", "{FullName}-{Id}/Events", "~/Events.aspx");
}
This is my code that i am using in my global.aspx
file under the Application_Start
method. by using this code, it is making url correct but not redirecting on any page and showing error is The: localhost page isn't working
localhost redirected you too many times. this error i am getting on the browser while i am running my project.
This is my problem please anyone resolve this problem and help me.
Just a stab...Not too sure if you can have parameters "dash" separated...have you tried.
routes.MapPageRoute("Dashboard", "{FullName}/{Id}/Dashboard", "~/Dashboard.aspx");
routes.MapPageRoute("Reviews", "{FullName}/{Id}/Reviews", "~/Reviews.aspx");
routes.MapPageRoute("Events", "{FullName}/{Id}/Events", "~/Events.aspx");
Also, your path is localhost/user/<URL Route>...
not too sure if it will work without the rest of the path in the routes
. Can you confirm your landing pages are being hit (put break in page_load
)?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.