Question

How can I route all requests to my HomeControllerand my Index Action?

So for example if a requested URL looks like this:

http://localhost/News/Tech/23

Then I'd like to "capture" that in my Index action:

public class HomeController
{
    public ActionResult Index (string uri)
    {
        // code
    }
}

So in this case the string url should contain: "News/Tech/23".

But I have no idea how to configure the route for this. Any idea how to do this?

Was it helpful?

Solution

Define route and as the route template provide the following

"{*uri}"

so something like

config.MapRoute("DirectToHomeIndex", "{*uri}", new {controller = "Home", action = "Index"} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top