can you explain me how to pass query string parameter in url vs. passing parameter as example /param1/2


i am trying to learn if i want to pass a parameter as param1/3   vs replies?param1=3

i would like to learn how to generate each of them what should i do, and which 1 i should prefer in my coding?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
The first one is the classic querystring way supported natively by

The second is based on routes, which is a commonly used in the MVC designs.
You can still use routes in webforms, but MVC makes it easier to implement.

So to put it simple, the choice is much related to how you want to build your site, Web Forms or MVC? :)
nicedoneAuthor Commented:
thanks for the explaination,

1) if i use mvc which i do at the moment and prefer to pass in

replies?param1=3 can i do that? if so could you show a little code snippet that accomplishes that

if i want to use param1/3 as in routes could you share a small code to accomlish that insted too
Alexandre SimõesManager / Technology SpecialistCommented:
The MVC routes don't work exactly like that.
The parameter name is not there, they are picked from where they are in the route.
For ex:
public class ReviewsController : Controller
    // eg: /reviews
    public ActionResult Index() { ... }
    // eg: /reviews/5
    public ActionResult Show(int reviewId) { ... }
    // eg: /reviews/5/edit
    public ActionResult Edit(int reviewId) { ... }

Open in new window

This means that the controller automatically maps the placeholder name with the method argument.

You can actually mix both routes and querystring in the same request:
    public ActionResult Edit(int reviewId, String name) { ... }

Open in new window

Can be called: reviews/123/edit?name=Alex

The example above was taken from here:

if i use mvc which i do at the moment and prefer to pass in replies?param1=3
Why would you want to do that anyway?
As I told you above, it's possible but you have to have a very specific reason for that...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.