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

  • Home
  • SEARCH
  • 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 6198429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:59:44+00:00 2026-05-24T03:59:44+00:00

I have read a few threads on StackOverflow about this, but cannot get it

  • 0

I have read a few threads on StackOverflow about this, but cannot get it to work. I have this at the end of my RegisterRoutes in Global.asax.

routes.MapRoute(
            "Profile",
            "{*url}",
            new { controller = "Profile", action = "Index" }
            );

Basically what I’m trying to achieve is to have mydomain.com/Username point to my member profilepage. How would I have to set up my controller and RegisterRoutes in order for this to work?

Currently mydomain.com/somethingthatisnotacontrollername gets a 404-error.

  • 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-24T03:59:46+00:00Added an answer on May 24, 2026 at 3:59 am

    Solution that works for your case but is not recommended

    You have a predefined set of controllers (usually less than 10) in your application so you can put a constraint on controller name and then route everything else to user profile:

    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional },
        new { controller = "Home|Admin|Reports|..." }
    );
    routes.MapRoute(
        "Profile",
        "{username}/{action}",
        new { controller = "Profile", action = "Details" }
    );
    

    But this will not work in case some username is the same as your controller name. It’s a small possibility based on experience end empirical data, but it’s not 0% chance. When username is the same as some controller it automatically means it will get handled by the first route because constraints won’t fail it.

    Recommended solution

    The best way would be to rather have URL requests as:

    www.mydomain.com/profile/username
    

    Why do I recommend it to be this way? Becasue this will make it much simpler and cleaner and will allow to have several different profile pages:

    • details www.mydomain.com/profile/username
    • settings www.mydomain.com/profile/username/settings
    • messages www.mydomain.com/profile/username/messages
    • etc.

    Route definition in this case would be like this:

    routes.MapRoute(
        "Profile",
        "Profile/{username}/{action}",
        new { controller = "Profile", action = "Details" }
    );
    routes.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies for the long post -- Read a few threads about this, but still
I have read quite a few selcet+update questions in here but cannot understand how
I've read a few threads on this subject but couldn't find anything to do
I know there have been a few threads on this before, but I have
I know there's tons of threads about this. And I read a few of
I'm fairly new to working with relational databases, but have read a few books
I have read this post about how to test private methods. I usually do
I read a few documents about Mutex and still the only Idea I have
I have read several threads about memory issues in R and I can't seem
First of all, I know there are a few other StackOverflow questions about this

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.