我有一个 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/