asp.net web api - angularjs technique for login then redirecting to dashboard page -
asp.net web api - angularjs technique for login then redirecting to dashboard page -
i'am doing first angularjs project asp.net web api backend. trying is, whenever user visits www.mydomain.com, login page (index.html) displayed. after successfull login, redirected dashboard.html (this shell page, partial views go here). project construction shown below-
i confused issues:
is best/common practices trying in above? as becausedashboard.html main page, should place app.js on dashboard.html? if set app.js on dashboard.html, index.html (login page) have app.js (i.e. loginapp.js)? how should manage login state i.e. isuserloggedid, userid etc in angular part? this question may silly. googled, did not find example/article addressing such issue. please help?
thank in advance.
i not sure how asp.net deals it, knowledge asp.net server side framework whereas angularjs client side framework. these 2 framework solve different problem, has overlapping features. if start using angularjs, of time deal term "single page application (spa)".
there different approaches in how can handle url redirection after login. show 2 example. there many more how can handle user authentication , session.
first approach: in spa, of time browser alter url route , state straight in page without making entire page request server. said, dashboard.html come static template file loaded browser directly. (i.e. server not dynamically parse dashboard.html serve static file). upon user login, angularjs fire asynchronous http request asp.net authentication end point. successful login may homecoming token browser, , client utilize manage user session. @ same time, angular have alter route /dashboard/. notice that entire flow happens transparent user, not fire total page http request.
second approach: alternatively, if take redirect server, have send http redirect 302. , since http redirect phone call create total http request /dashboard/, , have reload , bootstrap angular app.js browser again. in case, user have wait dashboard page processed server upon login
issues:
is best/common practices trying in above? there many approaches, think best find 1 works you. if have restful api, might want have @ spa approach in more detail. as because dashboard.html main page, should place app.js on dashboard.html? in spa, don't need load app.js twice. if utilize sec approach, have reloadapp.js again. if set app.js on dashboard.html, index.html (login page) have app.js (i.e. loginapp.js)? depends on approach stated above how should manage login state i.e. isuserloggedid, userid etc in angular part? authentication strategy, unix style authorization there more official guide can help angularjs developer guide.
hope helps integrate asp.net authentication mechanism.
angularjs asp.net-web-api single-page-application
Comments
Post a Comment