ASP.Net mvc2 url format issue
-
28-06-2021 - |
문제
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.
해결책
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?
다른 팁
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.
제휴하지 않습니다 StackOverflow