Вопрос

My English not wel, please bear with me a lot. routes in Global.asax file:

routes.MapRoute("Default","{controller}/{action}/{Page}/{id}",new { controller = "Home", action = "Index", Page = 0, id = UrlParameter.Optional });

I used @Html.Action write

@Html.ActionLink("LinkText","About",null,new{id="_ID"})

in View page. When opening url with

http://localhost/Home/About

in the broswer,The url result In the View page is:

http://localhost/Home/About

It's right! But When opening url with

http://localhost/Home/About/8

The url result In the View page is

http://localhost/Home/About/8

too. Why? This is a bug?

I want url is http://localhost/Home/About, Because the value of parameter named routeValues is null.

Это было полезно?

Решение

If you use null as your RouteValue then it will use the current RouteValues.

Rather use:

@Html.ActionLink("LinkText","About",new{page=0, id=""},new{id="_ID"})
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top