HttpContext.Current.User.Identity.Name is Empty

前端 未结 10 1493
礼貌的吻别
礼貌的吻别 2020-11-29 04:13

I have a Silverlight application (using MVC) and when i\'m building in visual studio, using Visual Studio Development center, there\'s no problem, the HttpContext.Curr

10条回答
  •  一个人的身影
    2020-11-29 05:06

    Apart from all obvious reasons mentioned earlier, there might be another one: you didn't put an Authorize attribute on top of your controller, like that:

    [Authorize(Roles = "myRole")]
    [EnableCors(origins: "http://localhost:8080", headers: "*", methods: "*", SupportsCredentials = true)]
    public class MyController : ApiController
    

    At least that's what worked for me.

提交回复
热议问题