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

The Archive Base Latest Questions

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

I don’t know how to ask this, and I don’t know what it is

  • 0

I don’t know how to ask this, and I don’t know what it is called either so I’ll just describe what I want to achieve.

In the database, some articles’ title originaly has spaces:

my title with spaces

But in the url, spaces are replaced by other characters such as plus sign (+) or underscore (_)

http://www.mydomain.com/mycontroller/myaction/my_title_with_spaces

or

http://www.mydomain.com/mycontroller/myaction/my+title+with+spaces

Now, how do you do that in C#? Or is there any helper in ASP.NET MVC that can do something like that?

Let say we achieved the said URL, is there any risk that two unique titles become the same in the URL? Please consider these titles:

Title's
Titles

after parsing, they became the same

Titles
Titles

This will be a problem when retrieving the article from the database since I’ll get two results, one for “Title” and one for “Title’s”.

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

    I would implement that functionality like this:

    1. When creating a new article, generate the URL representation based on the title.

    Use a function that converts the title for a suitable representation.
    For example, the title “This is an example” might generate something like “This_is_an_example”.

    This is up to you. You can create a function that parses the title with rules you define, or use an existing one if it suits better your problem.

    2. Ensure the URL representation is unique

    If it’s going to be an ID, it must be unique. So, when creating new articles you must query your database for the resulting URL representation. If you get a result from the database, it means the newly created article generated the same representation as one of the already created articles. Add something to it so it remains unique.

    This could be something like “This_is_an_example_2”. In this case, we added the “_2” to the end of the generated representation so it differs from the already existing one. Once more, with each change you have to ensure this representation remains unique.

    3. Save the created ID in the database, along with the article data

    In the database be sure to save the “This_is_an_example” ID and relate it to the article. Maybe even as the table primary key?

    4. Query the database for the correct article

    Now, about showing a site visitor the correct article:
    When a visitor asks for the following resource, for example:

    http://www.mydomain.com/mycontroller/myaction/this_is_an_example_2
    

    Extract the URL part that identifies the article, in this case “this_is_an_example_2”.

    When you have that, you have the identifier of the article in the database. So, you can query the database for the article with the “this_is_an_example_2” ID and show the article’s content to the user.

    This might involve some URL rewriting. Unfortunately I’m unable to help you with that in asp.NET. Some search on the subject will surely help you.

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

Sidebar

Related Questions

Don't know if this is the right place to ask this, but I will
Don't really know how to formulate the title, but it should be pretty obvious
Don't know if I worded the question right, but basically what I want to
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this has been asked before, so point me to another question
Don't know if anyone can help me with this or if it's even possible.
I don't know: if this works. if it's a good idea. what it is
I don't know if this question is trivial or not. But after a couple
Don't know where else to ask, but from one day to the other my
Don't know why this is happening, but after submitting a form via JS (using

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.