views:

86

answers:

1

On my HomeController I have an index action which redirects to the index action of the CustomerController via the RedirectToAction method. In this instance I don't like how RedirectToAction modifies the URL showing mysite.com/Customer. Are there some alternative mechanisms to performing a redirection that will allow me to still leverage the index action from the CustomerController?

public RedirectToRouteResult Index()
{
    return RedirectToAction("Index", "Customer");
}
A: 

As I understood it, RedirectToAction uses a reverse lookup on the routing table to generate its URL. So if you've told the Routing module that you want to map "/Customer/Index" to Controller Customer and Action Index then RedirectToAction will take your Index and Customer arguments and convert them to "/Customer/Index".

So if you want to change the behaviour of RedirectToAction you simply need to change your routing rules.

pdr