简体   繁体   English

登录表单身份验证之前Ajax调用不起作用

[英]Ajax call not working before login in form authentication

I am using cookie based form authentication in my application and login in my application through jquery ajax call.when i apply Authorization tag in my web.config.my ajax function stop calling login action method in controller. 我在我的应用程序中使用基于cookie的表单身份验证,并通过jquery ajax调用登录我的应用程序。当我在web.config.my中应用Authorization标签时,我的ajax函数停止在控制器中调用登录操作方法。 The issue is that before login form is not authenticated and ajax call fail to call server action method.how can i enable ajax call before login. 问题是登录表单未通过身份验证之前,ajax调用无法调用服务器操作方法。如何在登录前启用ajax调用。 here is my web.config code.if i remove "authorization" tag from my web.config code works fine. 这是我的web.config代码。如果我从我的web.config代码中删除“授权”标签,则工作正常。

  <authorization>
  <deny users="?"/>
</authorization>

You will need to turn off authentication on your login action (ie AllowAnonymous): 您将需要在登录操作中关闭身份验证(即AllowAnonymous):

   [AllowAnonymous]
    public ActionResult Login(string returnUrl)
    {
        ViewBag.ReturnUrl = returnUrl;
        return View();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM