Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bjarke Petersen 15 posts 113 karma points
    Oct 28, 2014 @ 12:44
    Bjarke Petersen
    0

    Partial view was not found or no view engine supports the searched locations

    Hi,

    Tried to follow the "Surface Controllers" tutorial on umbraco.tv - I cant figure out why it is not working...

    VS 2013 - new ASP.NET MVC 4 Web Application (Visual Basic though), removed the unnessesary files, NuGet Umbraco 7.1.8 - installed the txt starterkit.

    Created a model:

    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Web
    Namespace Models
    Public Class ContactFormViewModel
    Private _message As String
    Private _name As String
    Private _email As String
    Public Property Name As String
    Get
    Return _name
    End Get
    Set(ByVal value As String)
    _name = value
    End Set
    End Property
    Public Property Email As String
    Get
    Return _email
    End Get
    Set(ByVal value As String)
    _email = value
    End Set
    End Property
    Public Property Message As String
    Get
    Return _message
    End Get
    Set(ByVal value As String)
    _message = value
    End Set
    End Property
    End Class
    End Namespace

    Created the view (in /Views/Partials)

    @ModelType Umbraco_7_1_8.Models.ContactFormViewModel

    <form>
    @Html.TextBoxFor(Function(m) m.Name)
    </form>

    The Controller

    Imports System
    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Web
    Imports System.Web.Mvc
    Imports umbraco.Web.Mvc
    Imports Umbraco_7_1_8.Models
    Namespace Controllers
    Public Class ContactFormSurfaceController
    Inherits SurfaceController
    '
    ' GET: /ContactFormSurface
    Function Index() As ActionResult
    Return PartialView("ContactForm", New ContactFormViewModel())
    End Function
    End Class
    End Namespace

    Use the partialView in "umbLayout.cshtml" (txt starterkit)

    ....
    <body class="homepage">
    <!-- Header -->
    @Html.Action("Index", "ContactFormSurface")

    <header id="header">
    <div class="logo">
    <div> ....

    I get this System.web.HttpException: Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper

    Inner exception:

    The partial view 'ContactForm' was not found or no view engine supports the searched locations. The following locations were searched:
    ~/Views/ContactFormSurface/ContactForm.aspx
    ~/Views/ContactFormSurface/ContactForm.ascx
    ~/Views/Shared/ContactForm.aspx
    ~/Views/Shared/ContactForm.ascx
    ~/Views/ContactFormSurface/ContactForm.cshtml
    ~/Views/ContactFormSurface/ContactForm.vbhtml
    ~/Views/Shared/ContactForm.cshtml
    ~/Views/Shared/ContactForm.vbhtml
    ~/Views/Partials/ContactForm.cshtml
    ~/Views/MacroPartials/ContactForm.cshtml
    ~/Views/ContactForm.cshtml

     

    So in ~/Views/Shared/ both ContactForm.cshtml and ContactForm.vbhtml are searched for, but in ~/Views/Partials/ only ContactForm.cshtml is searched ?????

    I dont get it.. please advise.

  • Danny Blatant 91 posts 358 karma points
    Oct 28, 2014 @ 19:18
    Danny Blatant
    100

    Hi Bjarke,

    I've spend some time lately going through the umbraco.tv guides, so perhaps I can help from my experiance.

    As per the umbraco.tv guides, the Partial view is in "~/Views/Partials/ContactForm.cshtml", is your partial view named/located contrary to this?

    You can always pass the compelte path to your partial in (including the extension) if youhave refactored or relocated it.

    I do however agree that it is weird it searches for VB.NET and C#.NET equivilents everywhere except in the Partials directory, perhaps this is an oversight, or perhaps its becasue of the way Umbraco's back end template editor works?

    Are you dead set with VB.NET (.vbhtml) as I've only ever seen guides using C# (.cshtml)??

    Kind Regards,

    Danny "Blatant"

  • Danny Blatant 91 posts 358 karma points
    Oct 28, 2014 @ 19:20
    Danny Blatant
    0

    Additionally,

    It seems it's an 'Umbraco thing'...

    Here's a thread with others trying to switch to VB.NET Razor views, with no success :

    http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/48653-How-to-create-vb-razor%28vbhtml%29-view-in-umbraco-701

  • Bjarke Petersen 15 posts 113 karma points
    Oct 29, 2014 @ 13:04
    Bjarke Petersen
    0

    Changing 

    Return PartialView("ContactForm", New ContactFormViewModel())

    to

    Return PartialView("~/views/Partials/ContactForm.vbhtml", New ContactFormViewModel())

    did the trick :) Thanks.

  • Danny Blatant 91 posts 358 karma points
    Oct 29, 2014 @ 13:08
    Danny Blatant
    0

    Cool, so forcing it does the trick thats good.

    I think your point that the innspected paths is a bit wrong as it doesn't even try to find vbhtml's in there, but hey at least there's a workaround.

    I use the same full path technique to serve partial views to embedded macro's in the RTE, these don't need to process the data (and they are out of context) so I didn't want them cluttering my Partials folders. Glad you're back in business :D

    Kind Regards,

    Danny "Blatant"

Please Sign in or register to post replies

Write your reply to:

Draft