c# - 网站在 MVC Controller 上请求 "Authentication Required",而不是其他 Controller

标签 c# model-view-controller iis-7 routing

我有一个 asp.net C# MVC 网站。它使用 SimpleAuthentication 和表单例份验证。一切正常,需要人们登录才能访问页面。但是,我有一个名为“ReportsController”的 Controller 。每当您转到此 Controller 中操作的 URL 时,它总是会在浏览器窗口中弹出“需要身份验证”。

它只为这个 Controller 而不是任何其他 Controller 这样做。该 URL 将为“www.domain.com/reports”。当我从 IIS 和我的开发服务器运行时,这个 URL 工作正常,但在我的实时服务器上却不行。这是在运行 IIS7。

我检查了我的 web.config,它肯定设置为 Forms 身份验证而不是 Windows。

任何人都知道为什么任何以“/Reports”开头的 url 都不起作用。我猜这是服务器特有的东西,例如 IIS 设置或 web.config 更改,但我不知道这是什么。

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

            return View();
        }
    }
}

网络配置:

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

最佳答案

原来服务器上运行的是 Sql Server Reporting Services。这会控制该服务器上所有网站上的“/Reports”URL。

我没有使用 SQL Server Reports,所以我转到服务器上的“Reporting Services Configuration Manager”并删除了它正在监听的 IP 地址和端口。如果您仍然需要使用它,您也可以更改它使用的 URL。

关于c# - 网站在 MVC Controller 上请求 "Authentication Required",而不是其他 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22349023/

相关文章:

c# - 在 C# 中使用数组成员编码(marshal)结构

c# - 无法在 DLL 'TaskDialogIndirect' 中找到名为 'ComCtl32' 的入口点

javascript - 在 Angular JS With Wcf Service 的飞行前响应中,Access-Control-Allow-Methods 不允许方法 PUT

c# - 这个 ConcurrentDictionary 线程安全吗?

web-services - 自签名证书 IIS7 - 根据验证程序,远程证书无效

ruby-on-rails - 带有IIS 7的IronRuby on Rails

.net - 如何以编程方式配置 IIS7? (不使用元数据库)

ruby-on-rails - 无法在 View Rails 4 中显示我的类别和子类别

c# - ELMAH 中的错误信号不适用于 ASP.NET MVC

python - 从另一个 View 重定向时 Django 渲染不工作