0

I have something like this:

public ActionResult Index(int id)
{
    if (UserHasPermission())
    {
        return View()
    }

    throw new HttpException(403, "You do not have permission");
}

and in my web.config I set this:

<customErrors mode="On">
  <error statusCode="403" redirect="/Error/403" />
</customErrors>

I want to know how to get this message 'You do not have permission' when the redirect to Error/403 is done.

4

1 回答 1

1

They are just the redirects to a given url and sends it the Url that caused the error. It does not, however, store any information, it's simply a url redirection.

More details here: Custom Error Page - Throw HttpException and have custom error page show message

于 2012-10-03T13:59:15.007 回答