0
剛開始鑽研路線Areas
。我在嘗試一些基本的東西之前,我很喜歡。當我在地址欄中輸入物理路線時,效果很好。但是,當我嘗試使用@Url.Action
或@Html.ActionLink
創建鏈接時,MVC無法弄清楚如何計算正確的路線。無法爲我的MVC區域呈現正確的網址
打字的工作原理: 所以,我所知道的路線是正確設置...
http://localhost:51515/intro/tutorials/one
我的控制器的樣子:
同樣,這解決了正確的,當我鍵入它地址欄...
[RouteArea("intro")]
[RoutePrefix("tutorials")]
[Route("{action}")]
public class IntroTutorialsController : Controller
{
public ActionResult One()
{
var path = @"~/Views/tutorials/intro/one.cshtml";
return View(path);
}
}
MY SAD嘗試以該URL:
顯然,問題是在這裏...
@Html.ActionLink("intro", "one", "tutorials", new { Area = "intro" }, null)
<a href="@Url.Action("one", "tutorials", new { Area = "intro" })">One</a>
這些沒有決心和/或無義......
一個側面說明:
如果我hand-type
網址進入鏈接...他們的工作。
例如:
- HREF = 「/介紹/教程/一個」