更新时间:2023-11-23 10:31:34
在MVC中,您没有链接到 views ;你链接到动作。
假设你有一个NewPage
动作HomeController
:public ActionResult NewPage()
{
返回查看();
}您可以使用
网址.Action
帮助链接到它:< a href =' @ Url.Action(NewPage,Home)' title = PáginadePrueba > TestPage < / a > 跨度>
I´m developing a MVC app just for learning purposes.
I added a new View in the /Views/Home directory, and I tried to access it from the Index View, but when I do it, get the error HTTP 404.
here´s the tag: href="~/Views/Home/NewPage" title="Página de Prueba">TestPage/a>
is it posible to do so ?. (add references between pages in the Home directory
I´m working with Visual Studio 2010 C#
What I have tried:
Just to check the functionality, I added another page, in the root directory of my app, and added another tag, (In the Index View) to see if it works, and it did.
My tag: href="../../ViewPage1.aspx" title="esta es otra página">Esta es otra página>
In MVC, you don't link to views; you link to actions.
Assuming you have aNewPage
action on yourHomeController
:public ActionResult NewPage() { return View(); }you can use the
Url.Action
helper to link to it:<a href='@Url.Action("NewPage", "Home")' title="Página de Prueba">TestPage</a>