angularjs - Angular Js SPA is not working after publishing in IIS 8.5 -


i'm using spa technique using angularjs in asp.net mvc framework,angularjs routing between pages working fine when it's run vs2013,but after hosting application in iis8.5 routing not working.

when run app using iis express url http://localhost:12345/#/home after publishing http://localhost/myapp/#/home

here app.js,

 $routeprovider.when("/home", {         controller: "homecontroller",         templateurl: "/app/views/home.html"     }); 

in index.html

<li> <a href="#/home">home</a></li> 

when publish app in windows azure, app working fine. because url myapp.azurewebsite.net. myapp.azurewebsite.net/#/home

how can host in local iis.

you find find answer -- absolute file path.

quick fix:

change templateurl: "/app/views/home.html" templateurl: "app/views/home.html" (remove heading slash)

answer:

if specify templateurl /app/views/home.html, starts /, tell browser root.

if webapp stored in http://localhost/myapp/, browser visit http://localhost/app/views/home.html template.

that explains why app works fine when places in root directory, not working in sub directories, http://localhost/myapp/#/home .

do not worry side effect of relative path. resources calculated relative index.html.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -