# Html.ActionLink in Litium 6 MVC

**URL:** <https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108>\
**Category:** Questions\
**Tags:** litium-6, accelerator\
**Created:** [June 7, 2018, 6:44am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108 "2018-06-07T06:44:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 7, 2018, 6:44am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/1 "2018-06-07T06:44:44Z")

</div>

How do I use Html.ActionLink i MVC?  
I want to reach controller “Product” with the method “DownloadPdf”. (public ActionResult DownloadPdf(string id){})

I have tried this code in the .cshtml “@Html.ActionLink(“Download PDF”, “DownloadPdf”, “Product”, new { id = Model.ProductItem.Id }, null)”  
But that only generates /.DownloadPdf?id=123  
I want to generate /Product/DownloadPdf/123 OR add .DownloadPdf?id=123 to the end of the url, I can reach the method with both urls, but the ActionLink is generating wrong url.

Litium version: 6

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [June 7, 2018, 7:24am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/2 "2018-06-07T07:24:29Z")

</div>

Try  
`<a href="@Url.Action(Model.LogoutPage, new { action = "Logout" })" class="logout" title="@Html.WebSiteString("LoginLogOutButton")">@Html.WebSiteString("FrameworkLogOut")</a>`  
(a sample from Accelerator Views\MypageB2B\Index.cshtml).

> In standard [ASP.NET](http://ASP.NET) MVC the delimiter slash (/) is used between the controller and action name or parameters, when using [ASP.NET](http://ASP.NET) MVC in Litium the first delimiter is changed to a dot (.). The reason is that the url parser needs to know where the url is ending and where the action (or parameter) is starting.

from [https://docs.litium.com/documentation/architecture/mvc](https://docs.litium.com/documentation/architecture/mvc)

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 7, 2018, 7:49am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/3 "2018-06-07T07:49:10Z")

</div>

I tried  
\<a href="@Url.Action(“DownloadPdf”, “Product”, new { id = Model.ProductItem.Id })" class=“test”\>Download PDF

But I still get /.DownloadPdf?id=“123”, since the Action removes the original url, any way to keep the original url or can i create a new route for this?

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [June 7, 2018, 8:13am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/4 "2018-06-07T08:13:09Z")

</div>

Use the Action()-method with the signature from my previous the example to use the extensionmethod provided by Litium.

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 7, 2018, 8:24am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/5 "2018-06-07T08:24:46Z")

</div>

Like this? It’s still the same result  
\<a href="@Url.Action(CurrentState.Current.Page, new { action = “DownloadPdf” })"\>Download Pdf

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [June 7, 2018, 8:38am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/6 "2018-06-07T08:38:28Z")

</div>

You should be calling the `Action` method in `Litium.Web.Mvc.UrlHelperExtension`.

Also add your ID: `<a href="@Url.Action(CurrentState.Current.Page, new { action = “DownloadPdf”, Id = Model.ProductItem.Id })">`

If you do what does your url look like?

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 7, 2018, 9:18am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/7 "2018-06-07T09:18:48Z")

</div>

Thanks, that works better, but now i got another problem, when i am in ProductController and use CurrentState.Current.Page i get the startpage? And i can’t get any page that is a “ProductPage”

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [June 7, 2018, 9:33am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/8 "2018-06-07T09:33:54Z")

</div>

On a productpage you can pass the current baseproduct/variant into your action using model binding.

> For automatic mapping of current entity (baseproduct, page etc.) from the input parameters in the request the word current should be used in the name, for example Page currentPage. When the parameter name starts with current the parsing of input parameters in the request is ignored, instead the parameter is only assigned from the values that is extracted from the url-parsing.
> 
> [https://docs.litium.com/documentation/architecture/mvc/model-binding-and-dependency-injection](https://docs.litium.com/documentation/architecture/mvc/model-binding-and-dependency-injection)

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 7, 2018, 9:48am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/9 "2018-06-07T09:48:18Z")

</div>

Thanks, but why are the ProductController mapped to startpage? This is a clean litium installation so i don’t think we have changed anything about that.

I can’t reach the methods in productController since there is no page for that controller

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [June 7, 2018, 10:16am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/10 "2018-06-07T10:16:35Z")

</div>

CurrentPage points to the current page in CMS, since products do not have CMS-pages you get the StartPage.

The accelerator has added a route that let you access controllers using `site.axd` so you should be able to write a url using that pattern:

```auto
RouteTable.Routes.MapRoute(
   "ControllerDirect", // Route name
   "site.axd/{controller}/{action}/{id}", // URL with parameters
   new {action = "Index", id = UrlParameter.Optional} // Parameter defaults
).DataTokens["SkipAutoLayout"] = true;

```

From _Litium.Accelerator.MVC/App\_Start/RouteConfig.cs_

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [June 7, 2018, 10:41am UTC](https://forum.litium.com/t/html-actionlink-in-litium-6-mvc/108/11 "2018-06-07T10:41:58Z")

</div>

Yes, I guess thats the only way, i was hoping for some nice way of using the Actionlink but I guess I have to hard code a link.  
Thanks!
