我的网站(带有实体框架的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)