question

Lco-4080 avatar image
0 Votes"
Lco-4080 asked AlbertKallal-4360 edited

hide Parameter name ?

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?


dotnet-aspnet-webforms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Lco-4080,
You need to tell us how you implemented the url so we can better help you.
If you are using Response.Redirect then just remove name=.
E.g:
change

  Response.Redirect("category.aspx?name=" + TextBox1.Text);

to

 Response.Redirect("category.aspx?" + TextBox1.Text);

Best regards,
Lan Huang


0 Votes 0 ·
AgaveJoe avatar image
0 Votes"
AgaveJoe answered AgaveJoe edited

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

surferonwww avatar image
0 Votes"
surferonwww answered

How about using the URL Rewrite Module?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlbertKallal-4360 avatar image
0 Votes"
AlbertKallal-4360 answered AlbertKallal-4360 edited

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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.