I have a question on how to configure the inbuilt login functionality URL in ASP.net MVC Angular template. The web api url for login is "Account/Login" . I add an href in layout.cshtml file as shown below

 <data-ng-class="{active : activeViewPath==='/contact'}">
<br>
< href='#/contact'>Contact</a></li>
<br>
 < data-ng-class="{active : activeViewPath==='/Login'}">
<br>
< href='~/Account/Login'>Login</a></li>

Now when I click any link(demo) , the functional URL is :
://ayz.com/#/demo

When I click Login (works fine):
://ayz.com/Account/Login#/home

When I click demo again (Account/Login gets appended):
://ayz.com/Account/Login#/demo

How to correct this ?

 $routeProvider
            .when('/home', { templateUrl: '/home/main', controller: 'MainController' })
            .when('/contact', { templateUrl: '/home/contact', controller: 'ContactController' })
            .when('/about', { templateUrl: '/home/about', controller: 'AboutController' })
            .when('/demo', { templateUrl: '/home/demo', controller: 'DemoController' })
            .when('/product', { templateUrl: '/home/product', controller: 'ProductController' })
share|improve this question

Make sure that ng-view /ng-route just changes the view that is a part of the angular only.!! As you were already in: //ayz.com/Account/Login

//ayz.com/Account/Login#/home

When you click on demo, the view is just getting updated:

//ayz.com/Account/Login#/demo

Make sure, you use angular route for Account/Logon too.

Try getting the usage of hashbang too.!! Angular js uses that and just updates the part after that for ng-view.!!

Firstly when you were in demo: ayz.com/#/demo with no MVC routing.

And later on when you clicked on Accountlogin the url changed to ayz.com/Account/Logon/#home

and now when you clicked on demo, the last hasbang part of url "#/home" will just be changed to "#/demo" as you are now in Account/Login. And note that Angular routing works only for one ng-View in a single page.

share|improve this answer
    
Sorry for not being clear . I need //ayz.com/#/demo when I click Demo and //ayz.com/Account/Login#/home when I click login . Where would I need to update it ? – user2814819 Jun 30 '14 at 11:19
    
That was fine. Just add Account/Logon to your routing too and access through that. – Vidhya Sagar Reddy Jun 30 '14 at 11:21
    
Still no luck : $routeProvider .when('/demo', { templateUrl: '/home/demo', controller: 'DemoController' })<br/> .when('/product', { templateUrl: '/home/product', controller: 'ProductController' })<br/> .when('/Account/Login', { redirectTo: '/Account/Login' })<br/> .otherwise({ redirectTo: '/home' }); – user2814819 Jun 30 '14 at 11:29

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.