Search code examples
c#asp.net-mvcumbraco7url.action

url.action not returning an url


my url.action wont return a href..

i have seen this question: Url.Action not outputting URL

but it did not seem to answer my question since i only use an action name and a controller name...

this is my anchor:

<a href="@Url.Action("HomePage", "HomePage")" class="logo"><strong>News page / blog</strong> by Name.</a>

it just returns an empty href=""...

my controller name is HomePageController, and my ActionResult is HomePage().

EDIT: i am also using umbraco on the project.


Solution

  • Custom controllers in Umbraco should inherit from Umbraco.Web.Mvc.SurfaceController.

    If you were to set up your controller like this:

    using System.Web.Mvc;
    using Umbraco.Web.Mvc;
    
    public class HomePageController : SurfaceController
    {
        public ActionResult HomePage()
        {
            return View();
        }
    }
    

    @Url.Action("HomePage", "HomePage") would then return "/umbraco/surface/homepage/homepage".