小编Mar*_*tin的帖子

ASP.NET MVC5:在单个页面上关闭Windows身份验证

我的网站(带有实体框架的ASP.NET MVC5)使用Windows身份验证系统.它非常有用,使我能够通过搜索Active Directory获得有关用户的更多信息.我可以使用电子邮件等信息自动填写表单字段...

Web.config文件:

[...]
<authentication mode="Windows" />
<authorization>
  <deny users="?" />
</authorization>
[...]
Run Code Online (Sandbox Code Playgroud)

我有一个Powershell脚本(做另一个工作),它必须访问网站的一个页面才能发送一些信息.我需要提供对脚本的访问权限,无需任何身份验证(仅为此操作/页面关闭Windows身份验证).我首先使用了属性AllowAnonymous,它没有任何效果.

在我的动作控制器:

[AllowAnonymous]
    public ActionResult ReceiveData(string scriptVersion, string content)
    {
        try
        {
            if (scriptVersion != null && content != null)
            {
                HttpUtility.UrlDecode(content);                    
                Xxxxx.UpdatexxxxxxServer(content); // I just replaced the name of my project
                return new HttpStatusCodeResult(200, "OK");
            }

            return new HttpStatusCodeResult(403, "You're not allowed to do this.");
        }
        catch(Exception e)
        {
            return new HttpStatusCodeResult(400, "Unable to execute this request on the DB. Detailed …
Run Code Online (Sandbox Code Playgroud)

c# asp.net authentication asp.net-mvc powershell

3
推荐指数
1
解决办法
4132
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

authentication ×1

c# ×1

powershell ×1