Remove ID from MVC URL

2.5k views Asked by At

I have a heref like this.

 <a style="background: #3DB39E; text-align: center; color: #ffffff; border: none; width: 60px;" class="btn btn-default" href="@Url.Action("EditAccountUser", "Account", new { id = item.UsersID })">Edit</a>

controller like this

 public ActionResult EditAccountUser(long id=0)
        {
           Return View();
        }

Route Config like this

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
               name: "Default",
               url: "{controller}/{action}/{id}",
               defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
           );

it gives me this http://exmaple.com/Account/EditAccountUser/7

I just want to remove "7" from above URL?

How I can do this?

Please let me know.

Thanks,

Vivek

1

There are 1 answers

3
Vijay Patel On

try to refer this might help you link

or simply use url mapping in web.config

<urlMappings enabled="true">
  <add url="~/somedirectory/" mappedUrl="~/somedirectory/1/"/>
</urlMappings>