C# 表单身份验证(一页除外)
嗨,我正在用MVC创建一个小网站,我有大约三个页面,我试图允许所有用户访问某个页面。该页面是在我的“HomeController索引”中创建的C# 表单身份验证(一页除外),c#,authentication,model-view-controller,web-config,C#,Authentication,Model View Controller,Web Config,嗨,我正在用MVC创建一个小网站,我有大约三个页面,我试图允许所有用户访问某个页面。该页面是在我的“HomeController索引”中创建的 这是我的web配置,但当我尝试在控制器操作上方添加[AllowAnonymous]属性时,它仍会重定向我 public class HomeController : Controller { [AllowAnonymous] public ActionResult Index() { } } 控制器的外观
这是我的web配置,但当我尝试在控制器操作上方添加
[AllowAnonymous]
属性时,它仍会重定向我
public class HomeController : Controller
{
[AllowAnonymous]
public ActionResult Index()
{
}
}
控制器的外观如何?仅供参考,MVC不支持基于web.config的安全性。它可能会起作用,但微软不推荐它,并积极劝阻它。见:
public class HomeController : Controller
{
[AllowAnonymous]
public ActionResult Index()
{
}
}