Copied to clipboard

Flag this post as spam?

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


  • Yannick Smits 321 posts 718 karma points
    May 12, 2013 @ 17:20
    Yannick Smits
    0

    SurfaceController results in 404 IIS page

    Per the instructions in the docs I have created a MySurfaceController class and saved it in /controllers. Created a html layout in /views/my/index.cshtml

    Then try to request:

    umbraco.local/umbraco/surface/my/

    which results in an IIS 404 (staticfile handler).

    What else should I do? I tried this both on 6.0.0 and 6.1.0. beta 2.

  • Sebastiaan Janssen 4838 posts 14286 karma points MVP admin hq
    May 15, 2013 @ 09:57
    Sebastiaan Janssen
    0

    Are you using your own global.asax? It should inherit from Umbraco.Web.UmbracoApplication. 

    Other than that, in a clean install this works.

    Make sure to check out my (very much work in progress) v6 examples site: https://github.com/nul800sebastiaan/Umbraco6Examples

    It shows you better ways of mixing umbraco and controllers/views. 

    Basically: If you need a form to be handled by a controller:

    • Create page with a template (MyTemplate.cshtml, an MVC View in ~/Views inheriting from UmbracoTemplatePage)
    • Create a partial view for the form, use Html.BeginUmbracoForm to wrap the form, the model is your model class (@model MyModel)
    • On your MyTemplate, add the partial and pass it an instance of your model: @Html.Partial("~/Views/Partials/MyForm.cshtml"), new MyModel())
    As I said, check out the examples site for a full implementation.
  • Yannick Smits 321 posts 718 karma points
    May 15, 2013 @ 12:15
    Yannick Smits
    0

    Thanks sebas. I have the standard global.asax. But after fiddling around a bit more I found out that the URL syntax is a little different than documented and it is not picking up default actions. So I'm able to request the web api using this syntax:

    http://umbraco.local/Umbraco/Api/MyApi/Post

    Notice the extra Api appended to the controller name and also the mandatory action name at the end (Post). Should I file this as a bug or am I misundertanding something about the URL syntax?

    I haven't had success with directly requesting the SurfaceController using the same technique though:

    http://umbraco.local/Umbraco/Surface/MySurface/Index
    Doesnt' work. But then maybe it  is not supposed to be requested directly as per your example project. 

    I've also had a look at your Umbraco6Example project. I now understand more about how the Surface controllers work and how they are hooked up using Html.BeginUmbracoForm. Would be great though if you could add a demonstration of how to use the new Localization API's so that I can solve this problem too.

  • Anton Oosthuizen 185 posts 441 karma points
    Dec 03, 2015 @ 07:32
    Anton Oosthuizen
    0

    Have you manage to solve this problem? I'm having the same but my surfacecotroller works fine in my dev environment but on production it gives a 404

  • Davor Zlotrg 6 posts 96 karma points
    Feb 11, 2016 @ 10:33
    Davor Zlotrg
    0

    You need to have the namespace in your controller.

    This will not work

    public class SearchController : SurfaceController
    {
        ...
    }
    

    but this will

    namespace Controllers
    {
         public class SearchController : SurfaceController
         {
             ...
         }
    }
    

    If you have umbraco v6 the routing will work without the namespace, but umbraco v7 for some reason requires it.

Please Sign in or register to post replies

Write your reply to:

Draft