Base solution for your next web application
Open Closed

angularjs and html5 url 404 error #555


User avatar
0
max created

hi, I am using angularjs and ui.router and I activated " $locationProvider.html5Mode (true ) ; " but I have a problem when I do refersh page : the browse show 404 error .. any solution?

br

Max


2 Answer(s)
  • User Avatar
    0
    marcosli created

    If you are using IIS you need to install URL Rewrite and make some modifications on the web.config.

    I followed this [http://www.advancesharp.com/blog/1191/angularjs-html5-mode-reloading-page-not-found-solution]) but is still not working.

    If you find a solution, could you post it here?

    Thanks!

  • User Avatar
    0
    thechrismarsh created

    Make sure you inject the location provider to the config ...

    appModule.config([
        '$stateProvider', '$urlRouterProvider', '$locationProvider',
        function ($stateProvider, $urlRouterProvider, $locationProvider) {
    
            $locationProvider.html5Mode(true);
    

    Also make sure you add this to the head of the layout.cshtml view ...

    <head>
    	<base href="/">
    

    following these two steps alone worked for me ... <ins><span style="color:#0040FF">/Application#/host/tenants</span></ins> turns into <ins><span style="color:#0040FF">/host/tenants</span></ins>