0

I have some filters set up on an MVC C# framework. From here I am try to render an error page. The error page renders correctly, but I want to pass data from the HandleUnautorizedRequest (that depends on which filter you fail) so far I have this. Is there any way to do something like this, but pass data over to the error page I have in shared. I have already unsuccessfully tried to use ViewData in the object constructor, but I might have just been doing it wrong.

The way our code base is structured I can't initialize any of my controllers from here either.

protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
    filterContext.Result = new ViewResult
    { 
        ViewName = "Error"
    };
}
nicmoon
  • 136
  • 1
  • 7

1 Answers1

0

Not sure how you tried to use ViewData, but you could give this a shot:

filterContext.Result = new ViewResult()
                                   {
                                       ViewName = "test",
                                       ViewData = new ViewDataDictionary()
                                                      {
                                                          { "key", "value"}
                                                      }
                                   };
MondayPaper
  • 1,569
  • 1
  • 15
  • 20