hide Parameter name ?

Lộc Đào 1 Reputation point
2022-11-10T09:26:00.453+00:00

I have the url: https://www.abc.com/category.aspx?**name**=value

I want to hide the name just show value this url become: https://www.abc.com/category.aspx/value

how can I do that?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,246 questions
{count} votes

3 answers

Sort by: Most helpful
  1. AgaveJoe 26,186 Reputation points
    2022-11-10T12:08:57.683+00:00

    Learn/Configure routing.

    How to: Use Routing with Web Forms

    Keep in mind, you tagged this question as MVC Core but the URL is clearly Web Forms. If you have an MVC application then see routing for MVC Core.

    Routing in ASP.NET Core

    0 comments No comments

  2. SurferOnWww 1,906 Reputation points
    2022-11-12T00:22:55.217+00:00

    How about using the URL Rewrite Module?

    0 comments No comments

  3. Albert Kallal 4,646 Reputation points
    2022-11-12T23:48:12.563+00:00

    Well, if you turn on friendly urls, then your path name would become this:

    https://www.abc.com/category/name/value

    So, I quite much always use friendly url's, and thus my users never see/have ".aspx" in any page on the site.

    And, this also means that URL's become search engine friendly, or say allow users to copy + share a link with greater ease.

    And, if you can make the assumption that the paramter "name" is the ONLY pramter you ever use?

    then your URL could become this:

    https://www.abc.com/category/value

    Or maybe you want this:

    https://www.abc.com/category/names/AcmeGoods

    In above, the base page name is www.abc.com/catagory.aspx, or now www.abc.com/catagory

    and parameters you add are done with "/" - that replaces the ?SomePName=SomeValue

    You can install friendly URL's via a nuget package.

    HOWEVER, make sure you have (make) a copy of the site, or say use GIT so you can roll this back if you don't like the results.

    Edit:
    Do note the above assumes that you want to have the "ID" or whatever in the URL.

    However, I often don't want (or like) having some "id=234" in the URL. this can be a security issue, and often makes the URL look poor anyway.

    So, from one page to the next, I tend to use session() to pass the value, and thus the value(s) are only exposed in code behind. Eihter way, adopting friendly URL's does clean up and make your URL's look rather nice.

    A good example of friendly URL's in action? Take a look at the URL of this page!

    0 comments No comments