Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:52:06+00:00 2026-06-17T16:52:06+00:00

I am trying to write an FilterAttribute, IExceptionFilter global error handling attribute which should

  • 0

I am trying to write an FilterAttribute, IExceptionFilter global error handling attribute which should serve up a custom error view. I override public void OnException(ExceptionContext context) and do

context.HttpContext.Response.Clear();
context.HttpContext.Response.TrySkipIisCustomErrors = true;
context.HttpContext.Response.StatusCode = 403;

context.ExceptionHandled = true;
context.Result = new ViewResult { ... not sure what to put here... }

which is where I am stuck.
Everything I have tried so far causes me to see internal server error pages. I suspect I want something like

context.Result = new ViewResult
{
    ViewName = "~/Errors/ReadOnlyMode.cshtml",
}

However that didn’t seem to work (internal server errors…).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:52:07+00:00Added an answer on June 17, 2026 at 4:52 pm

    This should work

    context.Result = new ViewResult
    {
        ViewName = "~/Views/Errors/ReadOnlyMode.cshtml",
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying write a query to find records which don't have a matching record
I've had problem when trying write a function which has a default value when
Trying to write Unit test for Silverlight 4.0 using Moq 4.0.10531.7 public delegate void
I trying to write a function - noPrime(X,Result) which gives a list of all
im trying to write hashtable between sockets in java but getting this error :
Trying to write a byte[] to a file, which i think is working correctly
I've been trying write an application which will be able to connect to a
Trying to write a regex matcher for roman numerals. In sed (which I think
We've been trying write unit tests for a worker class written in C#, which
Trying to write a GLOBAL CBT HOOK, this is My code, but my hooking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.