我创建了一个基于角色授权的mvc模板应用程序。当用户点击对他有意义的动作方法(比如说关于)时,他会被重定向到“关于”视图。但是当他点击另一个页面(前主页)然后又来到关于时出现问题。这次他被重定向到登录而不是关于页面。可能的原因/解决方法是什么?试图清除饼干,历史等任何帮助表示赞赏
[RequireHttps]
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[Authorize(Roles ="ADMIN")]
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
[Authorize(Roles ="ANOTHER")]
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
这是about.cshtml
@{
ViewBag.Title = "About";
}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>
<p>Use this area to provide additional information.</p>
这是Contact.cshtml
@{
ViewBag.Title = "Contact";
}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>
<address>
One Microsoft Way<br />
Redmond, WA 98052-6399<br />
<abbr title="Phone">P:</abbr>
425.555.0100
</address>
<address>
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br />
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
</address>