How to pass the parameters using @Url.ContentUrl??


Hi Guys,

     Using Url property how  can navigate to another page and i also want to pass the parameter along with navigation.


[ContentType(DisplayName = "BlogPage", GUID = "b50836e3-9efd-4a4d-b0ee-7ecad52a684d", Description = "")]
public class BlogPage : PageData


    Name = "Blog Link",
    Description = "",
    GroupName = SystemTabNames.Content,
    Order = 5)]
    public virtual Url BlogLink { get; set; }

    Name = "Main Heading",
    Description = "",
    GroupName = SystemTabNames.Content,
    Order = 2)]
    public virtual string MainHeading { get; set; }




@foreach (var i in




         <a target="heading" href="@Url.ContentUrl(Model.BlogLink)"></a>






i have written the above code, but i did not pass parameters to it



#180236 Jul 04, 2017 7:23
  • Member since: 2010

    What kind of parameters do you want to pass in?

    If it's a query string you can simply use:

    <a target="heading" href="@Url.ContentUrl(Model.BlogLink)?boo=foo"></a>

    #180243 Jul 04, 2017 10:12

    Hi Dejan Caric

        Thanks for your response, i want to pass the int,string type of parameters not query string.



    #180245 Jul 04, 2017 10:32
  • Member since: 2010

    What exactly are you trying to solve? You have ContentLink and UrlLink helpers that allow you to pass in IDictionary<string, object> for htmlAttributes, but I guess that's not what you're looking for.

    #180246 Jul 04, 2017 11:06
  • Member since: 2004

    I'm not sure if this is the problem you're referring to, but you are closing your a-tag immediately after you open it, and then adding the heading. It should be like this:

    <a target="heading" href="@Url.ContentUrl(Model.BlogLink)">@i.MainHeading</a>

    #180252 Jul 04, 2017 11:41

    I want to pass the MainHeading(i.e:-@i.MainHeading) value as parameter to action methos its string type.



    #180255 Edited, Jul 04, 2017 11:54

    Hi @kartheek,

    You can not pass action parameter directly through ContentUrl function. However you can append action parameter as querystring and your acation parameter will be populated with that.

    You can also try @Url.Action() and can pass actoin name, controller name and routevalues.


    #180322 Jul 06, 2017 6:40

    Hi @Murtaza ali,

               i also trying with @Url.Action() to navigate, but  i get an error. you can see the below code.


                  <a href="@Url.Action("Index", "Post")" > @i.MainHeading</a> and i using

                 <a href="@Html.Action("Index", "Post")">@i.MainHeading</a>

                  but this actions are not working


                   public class PostController : PageController<Post>
                         public ActionResult Index(Post currentPage)

                            return View();




                  IIS 10.0 Detailed Error - 404.0 - Not Found

                HTTP Error 404.0 - Not Found

                 The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
                IIS 10.0 Detailed Error - 404.0 - Not Found
                 Most likely causes:
    •  The directory or file specified does not exist on the Web server.
    • The URL contains a typographical error.
    • A custom filter or module, such as URLScan, restricts access to the file.
               To resolve the above error i   used @Url.ContentUrl but am unable to pass the parameters.
    #180326 Edited, Jul 06, 2017 9:05