Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What is the problem you are trying to solve? It sounds like you may be headed down a path to a complex solution that could use a simple solution instead.</p> <p>If a user doesn't have permissions to access the page after login, are you wanting non-logged in users to go to one page, while logged in users go to a different page?</p> <p>If that's the case I might be tempted to create another controller for just such scenarios and redirect to that controller anywhere the user doesn't have access. Or if you are using your own base Controller I would put the functionality there.</p> <p>Then the controller could present the desired view. For example if a non-logged in user tries to access a page they could get redirected to a generic error page. If the user is logged in, they could get redirected to a not authorized page.</p> <p>This is very similar to Robert's answer.</p> <p>Here's a basic skeleton for a base controller.</p> <pre><code>public BaseController: Controller { ... // Some code public ActionResult DisplayErrorPage() { // Assumes you have a User object with a IsLoggedIn property if (User.IsLoggedIn()) return View("NotAuthorized"); // Redirect user to login page return RedirectToAction("Logon", "Account"); } } </code></pre> <p>Then in lets say a AdminController (that inherits from BaseController) action</p> <pre><code>public ActionResult HighlyRestrictedAction() { // Assumes there is a User object with a HasAccess property if (User.HasAccess("HighlyRestrictedAction") == false) return DisplayErrorPage(); // At this point the user is logged in and has permissions ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload