Click here to Skip to main content
15,849,129 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Here I have 3 login cshtml files,when we write in address bar like abc.com/1 ,needs to
load login1.cshtml and when we call abc.com/2 needs to call login2.cshtml and if it is
abc.com/3 login3.cshtml should be call.

Any help would be greatly appreciated.

Regards,
Soumya.

What I have tried:

JavaScript
var myApp = angular.module('myApp ',[]);

myApp .config(function ($routeProvider, $locationProvider) {

        $routeProvider

        // route for the home page
        .when('/1', {
            templateUrl: 'Login/Login.cshtml'
           , controller: 'Login/Login'

        })

        // route for the about page
        .when('/2', {
            templateUrl: 'Login/Login1.cshtml'
           , controller: 'Login/Login1'
        })

        // route for the contact page
        .when('/3', {
             templateUrl: 'Login/Login2.cshtml'
           , controller: 'Login/Login2'
        });

        // use the HTML5 History API
        $locationProvider.html5Mode(true);
    });
Posted
Updated 22-Sep-16 22:15pm
v3

1 solution

I believe your routes aren't working because you haven't told your module that you are using ngRoute.

Change

JavaScript
var myApp = angular.module('myApp ',[]);


To

JavaScript
var myApp = angular.module('myApp ',['ngRoute']);
 
Share this answer
 
Comments
soumyaraj 23-Sep-16 3:17am    
Thank you for your reply.But after applying ['ngRoute'] still not working.

when I cheked http://localhost:50205/2 the following result are coming
The resource cannot be found.

Description: HTTP 404.
OkuDoku 23-Sep-16 4:10am    
Can you show your folder structure? It seems like your Url path is wrong. Also have you really called your controllers 'Login/Login'?
soumyaraj 23-Sep-16 5:31am    
'Login/Login' and 'Login/Login1' is an MVC controller(In Login controller Login/Login1 action result).Will it execute?
OkuDoku 23-Sep-16 6:04am    
Try with a tutorial first, like
http://www.codeproject.com/Articles/1010542/Angular-Tutorial-Part-Understanding-Single-page
because you don't seem to have understood the concept of this whole angular thingy. If it's not only the routing you have problems with, try the other parts too.
soumyaraj 29-Sep-16 10:07am    
Hi OkuDoku,Thank you for your prompt reply.I understood the situation which is using the
Angular routing.
But in the case of my requirement which method I can adapt?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900