Asp.net mvc 允许匿名访问单个mvc路由

Asp.net mvc 允许匿名访问单个mvc路由,asp.net-mvc,Asp.net Mvc,我想允许匿名访问单个路由: public class GestionPantallaController : Controller { private GestionPantallaRepository repo = new GestionPantallaRepository(); // GET: GestionPantalla public ActionResult Index() { var es

我想允许匿名访问单个路由:

public class GestionPantallaController : Controller
    {
        private GestionPantallaRepository repo = new GestionPantallaRepository();
        // GET: GestionPantalla
        public ActionResult Index()
        {
            var estado = repo.ObtenerEstado();
            return View(estado);
        }
        [AllowAnonymous]
        public ActionResult Estado()
        {
            var estado = repo.ObtenerEstado();
            return Content(JsonConvert.SerializeObject(estado), "application/json");
        }
    }
[AllowAnonymous]不起作用,我也尝试在web.config中添加

  <location path="GestionPantalla/Estado">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>

但我得到了错误“Location元素未使用:在GestionPantalla\Estado中找不到项目项”


我正在使用Active Directory进行身份验证

web.config一个不起作用,我认为是因为您的文件夹中没有该路径。当你说AllowAnonymous不起作用时,你到底得到了什么错误?您的IIS设置是否配置为允许此应用程序的匿名请求(以及经过身份验证的请求)?我正在本地使用IIS express从WPF应用程序发出请求以进行调试。我收到一个401.2错误。到目前为止,我已经通过在WPF
HttpClient
中使用
usedaultcredentials=true
使用了解决方法,但我不确定这是否会在生产环境中起作用。我可能会使用此WPF应用程序的凭据。这是我当前的web.config