简体   繁体   English

url.action不返回网址

[英]url.action not returning an url

my url.action wont return a href.. 我的url.action不会返回href ..

i have seen this question: Url.Action not outputting URL 我已经看到了这个问题: Url.Action不输出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=""... 它只是返回一个空的href =“” ...

my controller name is HomePageController, and my ActionResult is HomePage(). 我的控制器名称是HomePageController,我的ActionResult是HomePage()。

EDIT: i am also using umbraco on the project. 编辑:我也在该项目上使用umbraco。

Custom controllers in Umbraco should inherit from Umbraco.Web.Mvc.SurfaceController. Umbraco中的自定义控制器应继承自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". @ Url.Action(“ H​​omePage”,“ HomePage”)然后将返回“ / umbraco / surface / homepage / homepage”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM