简体   繁体   中英

Getting the IsAuthenticated status on WCF Data Services within the client

I have a wcf data service which authenticates the user with custom basic authentication. I used the tutorial on MSDN Blogs OData and Authentication – Part 6 – Custom Basic Authentication . So after authenticating the user against a database, the service sets

var principal = new GenericPrincipal( new GenericIdentity("user") );
HttpContext.Current.User = principal;

Within my service I can access the principals auth status via

HttpContext.Current.Request.IsAuthenticated

Is there also a chance to get the IsAuthenticated status on my WPF client?

Basic authentication is performed for every request. Your client doesn't keep any state related to authentication (except pre-authentication which skips 401 handshake). If your service requires authentication you know that you are authenticated if your call to WCF-Data Service succeeds. If you are not authenticated you will receive exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM