Can't get HttpContext.Current.User.Identity to work in my WebMatrix project

本秂侑毒 提交于 2019-12-13 20:29:05

问题


I want to capture the user opening my page in an internal Windows AD network.

I think I've tried everything:

@{
// other code
string user123 = HttpContext.Current.User.Identity;
}

and also

@{
// other code
<script>
    var user123 = HttpContext.Current.User.Identity;
</script>
}

And trying to use that later inside my HTML code. Or passing it as a parameter to a stored procedure inside my razor block.

Nothing. Either empty, runtime error, or undefined.

Note1: HttpContext is recognized by WebMatrix as an element.

Note2: I enabled Windows Authentication in the server.

Note3: My head is spinning from this.

Note4: I'm a total rookie, as I'm just getting started with this.

Note5: I tried Page.Current... but it doesn't recognize the Page element.

来源:https://stackoverflow.com/questions/14384891/cant-get-httpcontext-current-user-identity-to-work-in-my-webmatrix-project

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