Using Prism 6
The validation whenever user is granted to view certain view is done with ThreadPrincipal. This method works when view is created in the viewModel:
try{
View someView = new View ();
mainRegion.Add(someView , "viewName");
mainRegion.Activate(someView );
}
catch (SecurityException)
{
}
And view has:
[PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
However creating a view in a viewModel is not a good practice so if RequestNavigate to navigate between views is used:
_regionManager.RequestNavigate(RegionNames.ContentRegion, new Uri(viewName, UriKind.Relative));
And same try, catch wrapper is wrapped around:
try{
_regionManager.RequestNavigate(RegionNames.ContentRegion, new Uri(viewName, UriKind.Relative));
}
catch (SecurityException)
{
}
The exception is not caught.
Question: How to catch the exception?