1

I am using Angular JS, asp.net web api project.

When I route using the following url

http://localhost:3458/Profile

I get the following error

Description: HTTP 404. The resource you are looking for...

But when I use the following link

http://localhost:3458/#/Profile

I do not get the 404 error.

I have googled and looked at other Stack overflow answers to the same question but still no success. Here is my code.

appointmentReminderApp.config(function ($routeProvider, $locationProvider, $httpProvider) {
    $httpProvider.interceptors.push('authInterceptorService');
    $locationProvider.html5Mode(true).hashPrefix('!');
    $routeProvider
        // Auth 
        .when("/home", {
            templateUrl: "App/Home.html",
            controller: "HomeController"
        })
        .when("/Register", {
            templateUrl: "App/AuthForm/templates/register.html",
            controller: "authRegisterController"
        })
    .when("/Profile", {
        templateUrl: "App/ProfileForm/templates/profile.html",
        controller: "profileController"
    })
        // All else
        .otherwise({ redirectTo: "/home" });
});
2
  • to use html5 mode, you have to enable rewriting on your server as well as within the angular app. check here github.com/angular-ui/ui-router/wiki/… Commented Feb 10, 2015 at 4:28
  • I think the problem here is that the .nets MVC Routing it taking precedence Commented Feb 10, 2015 at 4:28

1 Answer 1

1

You have to configure your server to send any request for http://localhost:3458/Profile and any other URL you will be routing, to your actual angular app's page index.html or whatever your page is.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.