2

For example instead of using "http://localhost/#/Employee/5", I want to go to "http://localhost/Employee/5". I want the web server to return the exact same ~/Default.aspx page for all urls (not 404s). The url in the address bar must stay as /Employee/5 and not redirect to my base page. Then the javascript framework can route the url within my single-page-app.

I have the js client side already working (with pushState: true in my backbone.history.start - see Backbone routes without hashes?).

Community
  • 1
  • 1
Curtis Yallop
  • 6,696
  • 3
  • 46
  • 36

1 Answers1

2
// Put any special route exceptions here, above the catch-all rule below
// eg a non-backbone login-page, ajax web service routes matching "api/{controller}/{action}/{id}".

routes.MapPageRoute(
    routeName: "SinglePageApp",
    routeUrl: "{*url}",
    physicalFile: "~/Default.aspx",
    checkPhysicalUrlAccess: false
);

// MVC version of the above ASPX version:
routes.MapRoute(
    name: "SinglePageApp",
    url: "{*url}",
    defaults: new { controller = "Home", action = "Index" }
);
Curtis Yallop
  • 6,696
  • 3
  • 46
  • 36