Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have an Angular MVC app that has couple of controllers. Default and another custom controller that I added.

http://example.com/home/

http://example.com/ManageSummaryInfo/

All my business logic lies with ManageSummaryInfo Controller.

 routes.MapRoute(                        
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "ManageSummaryInfo", action = "HomePage", id = UrlParameter.Optional }
            );

In Angular Routing, I have it like this,

$routeProvider.when('/showsummary',
                        {
                            templateUrl: 'ManageSummaryInfo/ShowSummary',
                            controller: 'ShowSummaryController'
                        });
    $routeProvider.when('/showerror',
                        {                            
                            templateUrl: 'ManageSummaryInfo/ShowError',
                            controller: 'ShowErrorController'
                        });   
    $routeProvider.when('/showplatform',
                        {
                            templateUrl: 'ManageSummaryInfo/ShowPlatform',
                            controller: 'ShowPlatformController'
                        });

My Views are also configured around ManageSummaryInfo Controller, but when I run I get to the home page, after which I click on one of elements should take me to the next page. But, I dont get routed and I got 404 - The resource cannot be found.error.

This is how my views look,

Views
--ManageSummaryInfo
----HomePage.cshtml
----Index.cshtml
----ShowSummary.cshtml
----ShowError.cshtml
----ShowPlatform.cshtml

My question, is when we have controllers in our route (ie, http://example.com/ManageSummaryInfo/- how would Angular route things and why mine getting file not found error.

I'm new to C# MVC Framework. Am I missing something related to ASP.NEt Routing ?Any help would be appreciated. I have tried to be eloborate, but if you would need more info, I'm happy to provide more code(Pastebin or something.

Thanks in advance!

Edit:

Adding Controller Class as per request,

public class ManageSummaryInfoController : Controller
    {
        // GET: ManageSummaryInfo
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult HomePage()
        {
            return View();
        }

        public ActionResult ShowPlatform()
        {
            return PartialView("ShowPlatform");
        }

        public ActionResult ShowSummary()
        {
            return PartialView("ShowSummary");
        }

        public ActionResult ShowError()
        {
            return PartialView("ShowError");
        }
    }
share|improve this question
    
How does your menageSummaryInfoController look like? – Chris Hermut yesterday

1)In the view(html code) on the link(a element) with the href showsummary (and the other also) add '#' before 'showsummary'.

2)Check you have

<script src=https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-route.min.js></script>

3)Check you have dependecy to ng-route :

angular.module('myModule', ['ngRoute']);
share|improve this answer
    
I have added the references, Sir. Infact, When i hit the page directly, http://example.com/ManageSummaryInfo/HomePage and from there clicking on my DOM object that has href configured takes me to http://example.com/ManageSummaryInfo/showsummary page. How do i make it controller agnostic, like hit my http://example.com/HomePage and still take the action to my ManageSummaryInfoController ? – Learner 11 hours ago

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.