1

I know this can be done, but don't even know what its called to find a good tutorial from Google. I am using ASP.Net MVC4 and I have a controller called ePage, right now I can access what I want from a URL like this

  http://www.myUrl.com/ePage/{ACTION}/{PARAMETER as "id"}

how can I change the routing so that (just for this controller if possible) it is read like this

  http://www.myUrl.com/ePage/{PARAMETER}

I will always be using "Index" as Action for now.

If there is a simple answer to do that'd be awesome , if not just a point to the right direction for me to read and figure out.

2
  • If you are using index then the action is not required. Unless you set something else as the default action in your routes Commented Dec 27, 2012 at 3:16
  • @Garvin - I don't understand, say I put myUrl.com/ePage/my-paramater , then isn't it going to look for the action "my-parameter" in the controller "ePage" ??? or will it just know to go to myUrl.com/ePage/Index?id=my-parameter Commented Dec 27, 2012 at 3:19

1 Answer 1

4

In your Global.asax.cs under the RegisterRoutes method, you can try adding:

routes.MapRoute("MyNewRoute", "ePage/{param}", new { 
    controller = "ePage",
    action = "Index",
});

Your Index method must have an argument named param so that the routing will match.

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

1 Comment

read more here

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.