Partial view of "First.cshtml" not found or viewer does not support found locations

I am trying to call a partial view in a div by clicking. I wrote this

@Ajax.ActionLink("Second", "Second", new AjaxOptions()
{
    HttpMethod = "GET",
    UpdateTargetId = "partials",
    InsertionMode = InsertionMode.Replace
})

<div id="partials">
</div>

<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/additional-methods.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/mvc/5.2/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>

in my Index.cshtml. my controller looks like this:

public ActionResult Index()
        {
            return View();
        }

        public PartialViewResult Second()
        {

            return PartialView("Second.cshtml");
        }

but my error says that my partial view was not found in:

~/Views/switchPartial/Second.cshtml.aspx
~/Views/switchPartial/Second.cshtml.ascx
~/Views/Shared/Second.cshtml.aspx
~/Views/Shared/Second.cshtml.ascx
~/Views/switchPartial/Second.cshtml.cshtml
~/Views/switchPartial/Second.cshtml.vbhtml
~/Views/Shared/Second.cshtml.cshtml
~/Views/Shared/Second.cshtml.vbhtml

but I have it in the switchPartial folder .

If I write @Html.Partial("Second")in my div, it will correctly display my partial view

What did I do wrong?

+4
source share
1 answer

No need to include the file extension at the end of the partial name. Try:

return PartialView("Second");

, ViewEngines ( Second.cshtml, Second.vbhtml Second.aspx).

+4

All Articles