문제

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?

도움이 되었습니까?

해결책

Define route and as the route template provide the following

"{*uri}"

so something like

config.MapRoute("DirectToHomeIndex", "{*uri}", new {controller = "Home", action = "Index"} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top