0

I'm having problems when using this route:

routes.MapRoute("ProductIndex", "pr-{key}", new { controller = "Home", action = "Product" });

When the key contains 'pr-', the route doesn't work.

Example: http://.../pr-my-product-key-with-pr-key

1
  • I tested this in MVC3 and MVC4 and this type of route works. Commented Apr 1, 2012 at 8:00

1 Answer 1

1

Routes don't work the way you want them to work, but it's easily converted

change your route to:

routes.MapRoute(
     "ProductIndex", 
     "pr/{key}", 
      new { controller = "Home", action = "Product" });

and use:

http://.../pr/my-product-key-with-pr-key

or, if you really want to use that "way" you need to override the Initialization method of your main controller are check the link with StartWith() and redirect to the proper Controller.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.