I return “~/Error/Unauthorized” page if a user is not admin and tries to access certain controllers. Here is how I return the error page:
if (!Models.Authorization.AdminPageCheck(this.User))
return new RedirectResult("~/Error/Unauthorized");
I am able to do it for ActionResult methods, but not for string methods as it doesn’t return a view. How can I secure a string method?
You should change those methods to return
ActionResults.You can then
return Content(someText, "content/type")