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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:10:10+00:00 2026-05-18T09:10:10+00:00

I have a subscription based MVC 2 application with the basic .NET Membership service

  • 0

I have a subscription based MVC 2 application with the basic .NET Membership service in place (underneath some custom components to manage the account/subscription, etc). Users whose accounts have lapsed, or who have manually suspended their accounts, need to be able to get to a single view in the system that manages the status of their account. The controller driving that view is protected using the [Authorize] attribute.

I want to ensure that no other views in the system can be accessed until the user has re-activated their account. In my base controller (from which all my protected controllers derive) I tried modifying the OnActionExecuting method to intercept the action, check for a suspended account, and if it’s suspended, redirect to the single view that manages the account status. But this puts me in an infinite loop. When the new action is hit, OnActionExecuting gets called again, and the cycle keeps going.

I don’t really want to extend the [Authorize] attribute, but can if need be.

Any other thoughts on how to do this at the controller level?

EDIT: in the base controller, I was managing the redirect (that subsequently created the redirect loop) by modifying the filterContext.Result property, setting it to the RedirectToAction result of my view in question. I noticed everytime the loop occurs, filterContext.Result == null. Perhaps I should be checking against a different part of filterContext?

  • 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-05-18T09:10:11+00:00Added an answer on May 18, 2026 at 9:10 am

    Ok, so here’s my solution in case it helps anyone else. There’s got to be a more elegant way to do this, and I’m all ears if anyone has a better idea.

    In my BaseController.cs:

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            ViewData["CurrentUser"] = CurrentUser; // this is a public property in the BaseController
    
            if (CurrentUser != null && CurrentUser.Account.Status != AccountStatus.Active)
            {
                // if the account is disabled and they are authenticated, we need to allow them
                // to get to the account settings screen where they can re-activate, as well as the logoff
                // action.  Everything else should be disabled.
                string[] actionWhiteList = new string[] { 
                    Url.Action("Edit", "AccountSettings", new { id = CurrentUser.Account.Id, section = "billing" }), 
                    Url.Action("Logoff", "Account")
                };
    
                var allowAccess = false;
                foreach (string url in actionWhiteList)
                {
                    // compare each of the whitelisted paths to the raw url from the Request context.
                    if (url == filterContext.HttpContext.Request.RawUrl)
                    {
                        allowAccess = true;
                        break;
                    }
                }
    
                if (!allowAccess)
                {
                    filterContext.Result = RedirectToAction("Edit", "AccountSettings", new { id = CurrentUser.Account.Id, section = "billing" });
                }
            }
    
            base.OnActionExecuting(filterContext);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an ASP.NET MVC website. Following domain driven design, we have a service
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I have an MSDN subscription and I'm wondering what edition of Visual Studio 2008
I'm just a one-man software shop, and I currently have an MSDN subscription. It
I have created a one-time subscription in SSRS report manager 2008. However I keep
Have a n-tire web application and search often times out after 30 secs. How
I have an object class User < ActiveRecord::Base has_one :subscription end and I have
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution

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.