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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:42:38+00:00 2026-06-15T06:42:38+00:00

I am new to the ASP.NET MVC programming. I have the following code in

  • 0

I am new to the ASP.NET MVC programming.
I have the following code in my site which redirects all the unsigned users to pages located at folder \content\, depending the ending of the page that they are currently.
How can I modify this code in order to not do the redirect if the user has already been redirected to this page?

using System.Globalization;
using System.Web;
using System.Web.Mvc;

namespace MYSITE.Web.Infrastructure
{
    public class CategoryRedirectAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (((ViewResult)filterContext.Result).ViewName.StartsWith("ProductList", true, CultureInfo.InvariantCulture))
                {
                    var categoryProductPath = filterContext.RouteData.Values["categoryProductPath"].ToString().Split('/');
                    if (categoryProductPath.Length > 0)
                    {
                        HttpContext.Current.Response.Redirect("/Content/" + categoryProductPath[categoryProductPath.Length - 1]);
                    }
                }
            }
        }
    }
}
  • 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-15T06:42:39+00:00Added an answer on June 15, 2026 at 6:42 am

    You’re making life difficult for yourself. You can use role-based FormsAuthentication to identify users and the [Authorize] attribute on your controllers or action methods to can control who can do what.

    Hopefully, you’ll find this useful: http://msdn.microsoft.com/en-us/library/ff398049(v=vs.100).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created the following project structure for my new asp.net mvc project any
All, I'm starting a new ASP.NET MVC project which requires some content management capabilities.
I have a new ASP.NET MVC 3 project, and MVC and Razor are all
I have an ASP.NET MVC 4 application which uses the new ASP.NET Web API.
New to ASP.NET MVC and programming, and I have searched high and low for
I have a new asp.net mvc project and i am trying to figure out
I create new asp.net mvc 3 project. Copy there all controllers, classes and views
I'm not new to programming but am new to Visual Studio, MVC, C#, ASP.NET,
I have a new ASP.Net MVC application that I am about to start and
On a new ASP.NET MVC application we are following a TDD approach, using NUnit

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.