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

  • SEARCH
  • Home
  • 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 9117393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:53:13+00:00 2026-06-17T04:53:13+00:00

I am trying to item-level security. I have a service like the following: [DefaultView(Customer)]

  • 0

I am trying to item-level security. I have a service like the following:

[DefaultView("Customer")]
public class CustomerService : MyServiceBase
{
    public object Get(CustomerRequest request)
    {
         if (UserIsAuthorizedForCustomer(request.Id))
         {
             return new CustomerResponse { Customer = GetCustomer(request.Id) };
         }
         else
         {
             return this.Redirect("/AccessDenied.htm");
         }
    }
}

The problem I’m having is that when the auth check fails and the service returns the redirect response, it seems like the razor page is still being executed, but with a null Model resulting in a NullReferenceException. Am I doing something wrong?

Thanks!

  • 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-17T04:53:15+00:00Added an answer on June 17, 2026 at 4:53 am

    I’m not sure what your implementation of Redirect does, but the normal way to redirect to an error page is to just throw an exception which follows the redirection rules setup in your AppHost. e.g:

    if (!UserIsAuthorizedForCustomer(request.Id))
        throw new UnauthorizedException("Not Authorized");
    

    In your AppHost you can specify different redirection pages for different error codes, e.g:

    SetConfig(new EndpointHostConfig {
        CustomHttpHandlers = {
            { HttpStatusCode.NotFound, new RazorHandler("/notfound") },
            { HttpStatusCode.Unauthorized, new RazorHandler("/login") },
        }
    });
    

    Or if you only want 1 page you can specify a fallback for unhandled errors:

    SetConfig(new EndpointHostConfig {
        GlobalHtmlErrorHttpHandler = new RazorHandler("/error")
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jquery to find an item based on it's class name.
I have a table like this: Item { int ItemID int ParentID string Name
What I'm trying to do is make a multi-level menu. The menu can have
I'm trying to update an item inside my object graph which could span 'n'
Dear Scholars I am trying to parse a RSS feed with the following item
I'm trying to split some html content using php's preg-match-all function: <li class=cat-item><a title=blabla
I am trying to build a three level treeview in WPF. Basically, I have
I have a multi-level nav styled as an unordered list that looks like this:
I am trying to add a class of 'active' to a parent list item
I'm trying to compute item-to-item similarity along the lines of Amazon's Customers who viewed/purchased

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.