In my application I wish to block the ability for users to navigate to specific views from the browser. These ActionResults
and by extension Views
serve singular basic functions to which I call in my layout with Html.RenderAction("Action","Controller")
. In order to handle this, I am using [ChildActionOnly]
attribute on the various get requests. How would I go about redirecting these request to my custom 404 instead of the error page?
I have tried setting the ActionResult
to private which does send the user to a 404, however doing so causes the Html.RenderAction
to fail.
Here is my Web.config logic
<customErrors mode="On" defaultRedirect="~/Error">
<error redirect="~/Error/NotFound" statusCode="404" />
</customErrors>