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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:40:02+00:00 2026-05-27T23:40:02+00:00

I have an asp.net web application and right now users can get there profiles

  • 0

I have an asp.net web application and right now users can get there profiles by putting int http://www.webdomain.com/page.aspx?usename=myusername. I would like to change it to http://www.webdomain.com/username. Thanks for any help.

  • 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-27T23:40:02+00:00Added an answer on May 27, 2026 at 11:40 pm

    Sample IRouteConstraint:

    public class IsUserActionConstraint : IRouteConstraint
    {
        //This is a static variable that handles the list of users
        private static List<string> _users;
    
    
        //This constructor loads the list of users on the first call
        public IsUserActionConstraint()
        {
            _users= (from u in Models.Users.Get() select u.Username.ToLower()).ToList();
        }
    
    
        //Code for checking to see if the route is a username
        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            return _users.Contains((values["username"] as string).ToLower());
        }
    
    
    }
    

    And, to register the route in the Global.asax:

     routes.MapRoute(
                "User Profile", // Route name
                "{username}", 
                new { controller = "User", action = "Index", id = UrlParameter.Optional },//  This stuff is here for ASP.NET MVC
      new { IsUserAction = new IsUserActionConstraint() } //Your IRouteconstraint
            );
    

    In my case, my user list never changes during the application life cycle so I can cache it by using a static list. I would suggest that you modify the code so that you’re doing what ever check to make sure the value entered is a username inside of the Match.

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

Sidebar

Related Questions

I'm currently working on web application using VB in ASP.NET. Right now I have
I am developing an ASP.net Web Application. I have an weird incident right now:
This is odd, but we have written an asp.Net web application (all's well there)
I have an asp.net web application, which sends several emails to users during the
I have a asp.net web application which has a number of versions deployed on
I have an ASP.NET web application which does the following: Reads an Excel file.
I have one asp.net web application. It is using two membership provider. Two sign-in
I have an ASP.NET web application the entire site is browsed over HTTPS using
I have an asp.net web application written in C# using a SQL Server 2008
We have an ASP.NET web application hosted by a web farm of many instances

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.