Reputation: 21
I have an MV Studio MVC Project. It is running well. I have created one root page namely, Index.html. I would like to call "View/Account/Login.cshtml" page from "Index.html" page.
I have tried below options: a href="/Account/Login">Log in /a> a href="~/Controllers/Account/Login">Log in /a>
The following screenshots have project and error view: http://my.jetscreenshot.com/29065/20161202-ysmx-69kb
http://my.jetscreenshot.com/29065/20161202-lphy-32kb
Reply me if anyone has a good solution to an issue.
Thanks.
Upvotes: 2
Views: 3108
Reputation: 309
The path is not correct in the given link:
http://my.jetscreenshot.com/29065/20161202-ysmx-69kb
It should be localhost:2300/Account/Login
ex.
<a href="/Account/Login">Login</a>
You don't need to add a Every MVC application must configure (register) at least one route, which is configured by MVC framework by default. You can register a route in RouteConfig class, which is in RouteConfig.cs under App_Start folder. The following code illustrates how to configure a Route in the RouteConfig class.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
Please find a link for more information below: http://www.tutorialsteacher.com/mvc/routing-in-mvc
Upvotes: 1
Reputation: 547
Use URL helper instead of hard coding the links as the code could break if you change your routing configuration in future.
<a href="@Url.Action("Index", "Home")">This</a>
Upvotes: 0
Reputation: 2607
Try to use
<a href="@Url.Action("Login", "Account")">Log in </a>
Where "Login" is action method and "Account" is controller name. This will render your login.cshtml view.
Dont use anyone of these
a href="/Account/Login">Log in /a> a href="~/Controllers/Account/Login">Log in /a>
Upvotes: 1