Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Your current route states that it should only match routes that start with api. Furthermore you're only mapping an HttpRoute (which is for ASP.NET MVC Web API)

Instead you should add a route like this:

routes.MapRoute(
                "Default",                                       // Route name
                "{controller}/{action}",                         // URL with parameters
                new { controller = "Home", action = "MyAction"}  // Parameter defaults
            );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.