Home Angular Routing with Asp.net mvc areas and cshtml not working
Reply: 0

Angular Routing with Asp.net mvc areas and cshtml not working

user4816 Published in September 19, 2018, 11:02 am

My layout.cshtml contains:

    <li><a href="#/User">User</a></li>
<div ng-view></div>

This is my controller:

and its action methods:

public class UserController : Controller

    // GET: Admin/Default
    BMS2Entities _db = new BMS2Entities();
    public ActionResult Index()
        var emp = _db.AspNetUsers.ToList();
        return Json(emp, JsonRequestBehavior.AllowGet);

And index.cshtml and index.js file inside:

index.js contains server call to usercontroller inside admin area:

app.controller('userController', function ($scope, $http) {

$http({ method: 'Get', url: 'Areas/Admin/User/Index' })
            .then(function (response) {
                $scope.depts = response.data;


and finally myapp.js file for routing:

var app = angular.module('myAppS', ['ngRoute']);

app.config(function ($routeProvider) {

$routeProvider.when('/User', {
    templateUrl: 'Areas/Admin/Views/User/Index.cshtml',
    controller: 'userController'

    redirectTo: '/'


but the codes are not working and it does not display cshtml and shows https://localhost:44382/Common/Home#/User in the browser.

share|improve this question

2 Answers 2

active oldest votes
up vote 1 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.343334 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO