0

Is it possible to have route like this : www.MyDomin/AnyPage www.MyDomin/AnyPage1 and so on ? Instead of www.MySite/MyController/AnyPage

Without specifying the controller?

2 Answers 2

1

Well you could define the following route:

routes.MapRoute(
    "Default",
    "{page}",
    new { controller = "Home", action = "Index", page = UrlParameter.Optional }
);

Now all that's left is have the controller action to which this would map:

public class HomeController: Controller
{
    public ActionResult Index(string page)
    {
        ...
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

Yes it is. Edit your routes in the Global.asax file, for example:

routes.MapRoute(
  "MyTerrificRoute",
  "{action}",
  new { controller = "MyController", action = "Index" }
);

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.