I try to add new static HTML page in project, for this I added link from one page to new page:
<a class="contact__item-link" href="~/Views/Home/Faq.cshtml" target="_blank">FAQ</a>
Also created file in Views/Home/Faq.cshtml
. It does not work
I try to add new static HTML page in project, for this I added link from one page to new page:
<a class="contact__item-link" href="~/Views/Home/Faq.cshtml" target="_blank">FAQ</a>
Also created file in Views/Home/Faq.cshtml
. It does not work
By default, you cannot directly browse View in ASP.Net MVC. You will need Controller, Action Method and View.
For example,
public class HomeController : Controller
{
public ActionResult Faq()
{
return View();
}
}
Then you can use either
@Html.ActionLink("FAQ", "Faq", "Home", new { target = "_blank" })
OR
<a href="@Url.Action("Faq", "Home")" target="_blank">FAQ</a>
FYI: Although you can modify to serve cshtml file; it is not a recommended approach in regular ASP.Net MVC. You can read more here.
If you really mean html
then it is html
e.g. foo.html
(or .htm
if you want)
cshtml
is not "static" as stated in the comments. Unless your site is an ASP.Net WebPages
web site, then cshtml
(and vbhtml
) "files" are restricted by default.
MVC
), then you can override this behavior (but likely not what you would want)Hth.