locked
SPA angularjs with MVC - partial view lose layout on refresh ? RRS feed

  • Question

  • User-1846805900 posted

    Hi

    i have create new SPA project and work on it with angularjs & mvc partial views it works fine, but i had one problem when i refresh page i got the partial view without any layout No css files & No script Files - first time i got page as:

    and everything is working fine, but when i refresh i got it as:

    angular route js;

    app.config(function ($routeProvider, $locationProvider) {
        $routeProvider.when('/AllCustomer', 
                            {
                                templateUrl: 'Customers/AllCustomer', 
                                controller: 'AllCustomersController' 
                            });
    
        $routeProvider.when('/AddNewCustomer', 
                            {
                                templateUrl: 'Customers/AddNewCustomer', 
                                controller: 'AddCustomerController' 
                            });
    });

    final result is:

    http://localhost:51798/#/AddNewCustomer
    
    http://localhost:51798/#/AllCustomer

    now refresh is working as i need but url still have "#"

     try to use html5Mode to remove # as :

        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false,
            hashPrefix: '!'
        });

    but when # still in <a> nothing happened and page content don't load &  i got url as:

    http://localhost:51798/#%2FAddNewCustomer
    
    http://localhost:51798/#%2FAllCustomer

    and if i remove # from <a> gor url as:

    http://localhost:51798/AddNewCustomer
    
    http://localhost:51798/AllCustomer

    but refresh not working 

    so please :

    ** did i must use # to let it work on refresh ?

    ** are there no other way to make partial view get layout on refresh and make url don't has "#" ?

    Monday, July 6, 2015 4:26 AM

Answers

  • User-1846805900 posted

    Thanks a lot - i fix it by using # in the URL

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 12, 2015 8:12 PM

All replies