Answer the question
In order to leave comments, you need to log in
How to specify that a certain Page opens in the specified Route?
Good evening. I can’t figure out how to make sure that the same Page that is not on the default path is displayed with the specified Route. For example, when I go to the path https://localhost:44388/Jvnlp, the application says that it cannot find "View" Jvnlp.cshtml, although it is located on the path ~/Pages/Jvnlp.cshtml
InvalidOperationException: The view 'Jvnlp' was not found. The following locations were searched:
/Views/Views/Jvnlp.cshtml
/Views/Shared/Jvnlp.cshtml
/Pages/Shared/Jvnlp.cshtml
<nav>
<div>
<ul>
<li>
<a asp-area="" asp-controller="Views" asp-action="Jvnlp">ЖВНЛП</a>
</li>
</ul>
</div>
</nav>
Answer the question
In order to leave comments, you need to log in
So far I have found such a solution indicating the full path to the view, which I don’t want to somehow consider as a solution, but what other ways are there, dear experts?
public class HomeController : Controller
{
public IActionResult Index()
{
return View("~/Views/Some/Index.cshtml");
}
}
I don't fully understand the question, but I'll try to help. In the route, write the default page at startup, on mvc 5 it is done like this, in the route config class:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Название твоей стартовой страниц", id = UrlParameter.Optional }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question