允许匿名访问单个mvc路由

时间:2018-06-06 13:01:34

标签: asp.net-mvc

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

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>

但我收到错误&#34;位置元素未使用:在GestionPantalla \ Estado&#34;

找不到项目项目

我使用Active Directory进行身份验证

0 个答案:

没有答案