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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:27:01+00:00 2026-05-23T17:27:01+00:00

Hi there I am looking for a solution to solve this problem.I am building

  • 0

Hi there I am looking for a solution to solve this problem.I am building an Web app with Asp.net mvc3.
I want to make a custom Action Filter ([KeyAuthorization]) so that only authorized key will access the controllers.

This is my default Route

routes.MapRoute(
                "Default", // Route name
               "{guid}/{controller}/{action}", // URL with parameters
               new { guid = UrlParameter.Optional, controller = "Home", action = "Index", }

So let say someone access the http://www.example.com/34safd-234s/home/index

if key:34safd-234s is correct (authorized) than the user will see the content otherwise the web app will throw an 404.

How can achieve this?

Thank you,

How can I build and action filter that checkes that guid parametre exist in the

  • 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-23T17:27:01+00:00Added an answer on May 23, 2026 at 5:27 pm

    You can do it by creating an ActionFilterAttribute. This should get you going in the right direction. You’ll need to do your validation where commented.

    public class KeyAuthorizationAttribute : ActionFilterAttribute {
        public override void OnActionExecuting(ActionExecutingContext filterContext) {
            var guidValue = filterContext.RouteData.Values["guid"];
            if (guidValue != null) {
                Guid guid = new Guid(guidValue.ToString());
                bool notValid = true;
                //do validation
                //set notValid = false if authorization passes             
    
                if (notValid) {
                    filterContext.Result = new HttpNotFoundResult();
                }
            }
        }
    }
    

    You would then apply this to your action.

    [KeyAuthorization]
    public ActionResult Index() {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a better solution to the problem of looking up multiple known IDs
I'm looking for an elegant, high performance solution to the following problem. There are
I'm building an ASP.NET MVC site where I want one of the Views I
I am new to MongoDB, but am looking at it to solve this problem:
I'm looking for a solution for this problem in C or C++. edit :
I realize there are several solutions to this problem. I am looking for advice
I should clarify that I am looking for a client-side solution. Alternatively, is there
Looking at the processmodel element in the Web.Config there are two attributes. maxWorkerThreads=25 maxIoThreads=25
I've inherited an enormous .NET solution of about 200 projects. There are now some
I'm looking for a generalized solution for this. Consider 2 radio type inputs with

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.