1

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

Darama
  • 3,130
  • 7
  • 25
  • 34

2 Answers2

2

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.

Community
  • 1
  • 1
Win
  • 61,100
  • 13
  • 102
  • 181
0
  • 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.

    • If you have an ASP.Net Application (e.g. MVC), then you can override this behavior (but likely not what you would want)

Hth.

EdSF
  • 11,753
  • 6
  • 42
  • 83