ASP.NET WebAPI Basic Authentication always fails as 401/Unauthorized

梦想的初衷 提交于 2019-12-04 03:04:21

Don't set the Principal on the Thread.CurrentPrinicipal any more. Use the Principal on the HttpRequestContext.

user3003443

In my case, following Darrels approach, I commented out the below and used his approach. It work great!... saving me hours

// Thread.CurrentPrincipal = PrincipalProvider
//     .CreatePrincipal(parsedCredentials.Username, parsedCredentials.Password);


   request.GetRequestContext().Principal = PrincipalProvider
       .CreatePrincipal(parsedCredentials.Username, parsedCredentials.Password);

Add the following to rest/resource sever and authentication server web.config

You must generate your own keys using http://www.codeproject.com/Articles/221889/How-to-Generate-Machine-Key-in-IIS

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!