Getting error after pushing to Windows Azure: You do not have permission to view this directory or page

后端 未结 9 1396
[愿得一人]
[愿得一人] 2020-12-15 16:30

I have googled for the past 3 hours and found nothing on what to do with respect to the windows azure problem:

You do not have permission to view this

9条回答
  •  佛祖请我去吃肉
    2020-12-15 16:46

    I hit this error too. I am using MVC and the reason for the error was that on my layout page I had a call to an action that isn't accessible to anonymous users:

    @Html.Action("GetMenu", "Users")  
    

    For information, I register a AuthorizeAttribute() global filter in Application_Start and my Login action is decorated with AllowAnonymous:

        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Login(LoginModel model, string returnUrl)
        {
    

    My website did work previously on IIS7, but Azure is less forgiving. I fixed the problem by adding a check like this:

    @if (User.Identity.IsAuthenticated)
    {
         @Html.Action("GetMenu", "Users")
    }
    

提交回复
热议问题