Visual Studio 2015 を使用して Asp.net Core 1.0 (WebApi) プロジェクトを作成しています。テンプレートは ASP.NET Core Web アプリケーション (.NET Core)\WebApi (認証が選択されていません) です。
ValuesController で、そのメソッドを呼び出しているクライアントから Windows ID を取得したいと思います。
using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Http;
...
[Route("api/[controller]")]
public class ValuesController : Controller
{
[HttpGet]
[Route("GetIdentity")]
public string GetIdentity()
{
//method1
var userId = User.GetUserId();
//method2
var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
return userId;
}
}
method1
現在、およびで期待どおりの結果が返されませんmethod2
。何か考えがありますか?