asp.net mvc - check if user session has expired asp web api -
i experimenting in developing single page application using asp mvc 4 / web api , angularjs.
i using mvc controller actions return views , web api actions return json.
as web api part restfull , has no state, wondering how check if user session has expired. example: user clicking on button , leads request web api action json data. when request hits server want check if user session has expired.
as said rather new combination of technologies , wondering how can achieved. example appreciated. in advance.
web api introduced attribute [authorize]
provide security. can set globally (global.asx)
public static void register(httpconfiguration config) { config.filters.add(new authorizeattribute()); }
or per controller:
[authorize] public class valuescontroller : apicontroller{ ...
if user authenticated(session has not expired) service work if not http 401 unauthorized
returned.
Comments
Post a Comment