0

In my mvc2 project, some URL are shown in the browser like this,

localhost:53289/Paper/ViewAgendaPaper?MeetingId=186&type=2&RefId=186

but i prefer to look it like this,

localhost:53289/Paper/ViewAgendaPaper

In my Global.asax,

routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Default", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

How to hide the id fields in the URL. Please give me some idea. Thankyou.

Dilma
  • 625
  • 3
  • 10
  • 22

2 Answers2

3

As far as I think you can't hide the Ids as they are supposed to be passed to fetch the exact data, however instead of

localhost:53289/Paper/ViewAgendaPaper?MeetingId=186&type=2&RefId=186

you can have it like:

localhost:53289/Paper/ViewAgendaPaper/186/2/186

Going through this post will help you more: How can I create a friendly URL in ASP.NET MVC?

Community
  • 1
  • 1
Imran Balouch
  • 2,170
  • 1
  • 18
  • 37
  • The place where you are making the above link, simply change it and make it to appear like the one i told you and things will work fine. – Imran Balouch Aug 27 '12 at 07:01
1

You cannot do what you are asking for with a simple link. An anchor link <a>...</a> performs a simple GET. If you want to hide the parameters, you would need to do a POST to the page in question.

Babak Naffas
  • 12,395
  • 3
  • 34
  • 49