I have a controller that should only be accessed if an attribute in my table is "true". Is there any way the user can click on that link, check if the attribute is true, and then release the access?
I have a controller that should only be accessed if an attribute in my table is "true". Is there any way the user can click on that link, check if the attribute is true, and then release the access?
You can let the user access the Controller without problems. Just create a business rule that does not allow you to continue:
public ActionResult AdicionarCapitulos(int id)
{
var publicacao = contexto.Publicacoes.SingleOrDefault(p => p.Id == id);
if (!publicacao.Validada)
{
ModelState.AddModelError("", "Publicação ainda não validada. Não é permitido a edição.");
return RedirectToAction("Index", "Publicacoes");
}
// Coloque aqui o resto da lógica
}