1

I made an annotation for pages that require logging in, if the user is not logged in it will be redirected to the login page. I would also like to add an error which requires tempdata to view the error. Otherwise i have to set an message and check if the user is logged in every controller.

So my question is if it's possible to set a tempdata in a non controller, if it's possible how could i achieve this?

1 Answer 1

1

Do you mean you made a action filter for those pages? If so, you can access tempdata in the filter context.

public void OnActionExecuting(ActionExecutingContext filterContext)
{
    filterContext.Controller.TempData
            ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.