0

I am having a website, say www.mywebsite.com, to which I want to add my ASP.NET MVC application which could be accessible from the link www.mywebsite.com/MyApplication. The problem begins when the action method of a controller is called which redirects to mywebsite.com/Home/MyAction which gives a 404. The route mapping done currently is as follows:

routes.MapHttpRoute(
            name: "API Default",
            routeTemplate: "api/{controller}/{action}"
        );

Please advice me on what I should be follow regarding the routing.

4

1 回答 1

1

您当前的路线声明它应该只匹配以 . 开头的路线api。此外,您只映射一个 HttpRoute(用于 ASP.NET MVC Web API)

相反,您应该添加这样的路线:

routes.MapRoute(
                "Default",                                       // Route name
                "{controller}/{action}",                         // URL with parameters
                new { controller = "Home", action = "MyAction"}  // Parameter defaults
            );
于 2013-05-29T07:39:47.563 回答