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 8864805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:20:40+00:00 2026-06-14T16:20:40+00:00

If a membership user try to get access to a specific folder and it

  • 0

If a membership user try to get access to a specific folder and it is now allowed by roles, the system is redirected to /Account/Index and asks for login and password again.

I would like to change that behavior since the user is already logged in and I just want to redirect to another /controller/action.

Could I get some help from here?
Thanks in advance.

  • 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-14T16:20:41+00:00Added an answer on June 14, 2026 at 4:20 pm

    I do something similar in all of my web applications. If a user has authenticated, but does not meet the security requirements to view the page I throw an HTTP 403 exception and then display a specific view for the 403 exceptions.

    This is the snippet from my custom authorize attribute:

    protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) {
        if (filterContext.HttpContext.Request.IsAuthenticated) {
            //If the user is authenticated, but not authorized to view the requested page (i.e. not a member of the correct group), return an HTTP 403 exception.
            throw new HttpException(403, string.Format("The user {0} was not authorized to view the following page: {1}", filterContext.HttpContext.User.Identity.Name, filterContext.HttpContext.Request.Url));
        } else {
            base.HandleUnauthorizedRequest(filterContext);
        }
    }
    

    And here is the snippet from my Global.asax where I actually perform the view response (this assumes an ErrorController exists and then a view called Error403:

    protected void Application_Error() {
        var exception = Server.GetLastError();
        var httpException = exception as HttpException;
    
        Response.Clear();
        Server.ClearError();
    
        var routeData = new RouteData();
        routeData.Values["controller"] = "Error";
        routeData.Values["action"] = "Error500";
    
        Response.StatusCode = 500;
        Response.TrySkipIisCustomErrors = true;
    
        if (httpException != null) {
            Response.StatusCode = httpException.GetHttpCode();
            switch (Response.StatusCode) {
                case 403:
                    routeData.Values["action"] = "Error403";
                    break;
                case 404:
                    routeData.Values["action"] = "Error404";
                    routeData.Values["message"] = httpException.Message;
                    break;
                case 500:
                    routeData.Values["action"] = "Error500";
                    break;
            }
        }
    
        IController errorsController = new ErrorController();
        var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
        errorsController.Execute(rc);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get user roles from Membership provider? Suppose I have a username and
for security reason, what is the minimum access level the asp.net membership user could
I'm having a logged in user create another user (different roles) using Membership.CreateUser. After
i have two entities one called User and another called Membership which has a
I've created my own signup form and creating the user using the Membership class.
I have a website that's using forms authentication and membership. A user must have
We've implemented a Membership Provider that authenticates to Active Directory and it's using System.DirectoryServices.
I have some code that is accessing Membership.GetUser() to get the current logged in
I am trying to get a user to enter their details and then store
I am using asp.net membership and trying to update a users details but get

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.