Website asks for “Authentication Required” on an MVC controller, but not others

懵懂的女人 提交于 2019-12-08 19:44:14

问题


I have an asp.net C# MVC website. It uses SimpleAuthentication and forms authentication. Everything works fine, requiring people to log in to go to pages. However, I have one controller called "ReportsController". Whenever you go to the URL's of the actions within this controller it always pops up with "Authentication Required" in the browser window.

It is only doing it for this controller and not any others. The URL will be "www.domain.com/reports". This URL works fine when I run from IIS and from my development server, but not on my live server. This is running IIS7.

I have checked my web.config and it is definately set to Forms authentication and not Windows.

Anyone have any ideas why any urls beginning with "/Reports" would not work. I am guessing it is something specific to the server, such as an IIS setting or web.config change, but I cannot figure out what this would be.

namespace ProjectName.Controllers
{
    public class ReportsController : Controller
    {
        public ActionResult Index()
        {
            throw new SystemException("here");

            return View();
        }
    }
}

Web.config:

<authentication mode="Forms">
  <forms loginUrl="~/" timeout="2880" />
</authentication>

回答1:


So it turns out that Sql Server Reporting Services was running on the server. This was taking control of the "/Reports" URL on all websites on that server.

I am not using SQL Server Reports, so I went to "Reporting Services Configuration Manager" on the server and removed the IP address and port it was listening on. You can also change the URL it uses instead if you still need to use this.



来源:https://stackoverflow.com/questions/22349023/website-asks-for-authentication-required-on-an-mvc-controller-but-not-others

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!