+1-888-365-2779
Try Now
More in this section

Using MVC

17 posts, 0 answered
  1. Stuart Hemming
    Stuart Hemming avatar
    144 posts
    Registered:
    07 Jul 2004
    26 Jul 2012
    Link to this post
    I'm a webforms developer. I can say, just, that I know the difference between MVC and a hole in the ground, but only just.

    I'm doing some reading on the MVC principles but wondered if anyone can offer me a good place to start wrt Sitefinity.

    -- 
    Stuart
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    26 Jul 2012
    Link to this post
    you'll definitely want to take a look at the Getting Started Guide, here's the first video in that section: Creating a Hello World Widget using Sitefinity MVC 

    Another good example is the Sitefinity MVC Store project which is a Sitefinity version of the original Microsoft ASP.NET MVC Store sample. It shows how you can use MVC together with the module builder to make a pretty solid solution!

    The full source code for the project is available for download and I think is a really good way to get familiar with using Sitefinity with MVC.

    Hope this is helpful!
  3. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    26 Jul 2012
    Link to this post
    I actually found this article to be more valuable in making my decision on whether or not to invest serious time in MVC.

    http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/how-does-sitefinity-use-asp.net-mvc

    I appreciate that MVC and Webforms each have their strengths, and supporting MVC is a great feature if you are already an MVC developer, but for me (as a webforms developer) and with Sitefinity being webform-centric... I'm comfortable with leaving MVC to others for now.
  4. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    26 Jul 2012
    Link to this post
    http://www.pluralsight-training.net is the best. Its not free, but I have learned so much about MVC there.
  5. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    26 Jul 2012
    Link to this post
    Agreed tht pluralsight is great! I try to watch at least one video every night. The Design Patters series alone makes me feel like I wasted 4 years money on college :P

    That being said, I'd like to say that this is another fine example of how Sitefinity is all about developer choice! Never feel compelled to use MVC just because it's there, we just want to give you the option :)

    We are not stopping our investment or development in web forms, and you absolutely can just keep doing what you're doing! If you decide to try MVC for something in the future, it will be there.

    thanks for your feedback!
  6. Stuart Hemming
    Stuart Hemming avatar
    144 posts
    Registered:
    07 Jul 2004
    26 Jul 2012
    Link to this post
    Andrei,

    I have a Pluralsight sub and I'm embarrassed to admit it never occurred to be to look there.

    I'm working my way through the MVC Fundimentals course.

    --
    Stuart 
  7. Stuart Hemming
    Stuart Hemming avatar
    144 posts
    Registered:
    07 Jul 2004
    26 Jul 2012
    Link to this post
    Am I'm right in thinking that, because I want to create widget with that uses a RadScheduler, I can't go the MVC route in this case anyway.

    -- 
    Stuart
  8. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    27 Jul 2012
    Link to this post
    @Josh,

    Since I'm like Stuart and dug a deep hole in the ground after an extensive WebForms background and moving into the PM/QA side of development, one thing still isn't clear to me - perhaps you can help me out with... 'Templates'.

    (please correct me where I'm wrong)
    If I'm not mistaking MVC doesn't have 'masterpages' like Webforms does, but uses shared views. When I go into Sitefinity's backend and choose Design > Templates I can choose create template from scratch (like you all do in the demos) and make it MVC.

    I imagine this somehow 'creates' a shared view that gets wired up when using that template on a page; and that being the magic of the patent. But what if I don't want an 'empty' template?

    Do you have a sample 'template' that has got some hard coded stuff on it, from which i can see-and-learn?

    ---
    The problem I'm having if I try and add a 'custom template' with something like this:

    <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>
     </head>
    <body>
        <div class="page">
                  <div id="title">
                    <h1>My MVC Application</h1>
                </div>
            <div id="main">
                @RenderBody()
            </div>
            <div id="footer">
            </div>
        </div>
    </body>
    </html>

    Sitefinity immediately complains about the head section, when I set it to runat=server, Sitefinity is kinda happy again. But MVC as far as I've learnt doesn't understand 'runat=server'. 

    Then when I create a page using that template I can edit that page in the editor - no sweat, Sitefinity renders it in the backend but when browsing the live page the system blows up into a nice YSOD.

    Like I said before I'm a MVC newbie. I've tried looking at all off Ivan's sample videos but they all use the 'empty' MVC template. And I'm sure when you go the MVC route and wire a shared view up through the code, it will work but where would that shared-layout be editable in Sitefinity then?

    Or are we only allowed/limited to use the empty template and need to build up that template from within Sitefinity?

    Jochem.
  9. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    27 Jul 2012
    Link to this post
    @Jochem Yeah I'm also a bit stuck on that concept...we certainly need the control of the core markup, but I can't get it to work either.
  10. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    13 Feb 2013
    Link to this post

    Wow almost a year and still no go on this. It looks like we need to override the template in the "PureMvcPageResolver" somehow. Maybe this can be done in the Bootstrapper in the Global.asax, but not sure of the API. I am hoping it can be done much easier than that though.. such as dropping a _ViewStart.cshtml file in the themes or Mvc folder, but that didn't work :(

    PureMvcPageResolver:

    Telerik.Sitefinity.Mvc.Rendering
    {
      public class PureMvcPageResolver : PageResolverBase
      {
        private string controllerPageTitle;
     
        protected override string DefaultFrontendPageTemplate
        {
          get
          {
            return "Telerik.Sitefinity.Resources.Pages.FrontendMvc.aspx";
          }
        }
        ...
      }
    }

    Telerik.Sitefinity.Resources.Pages.FrontendMvc.aspx:

    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        </head>
        <body>
            <div class="sfPublicWrapper" id="PublicWrapper">
            </div>
        </body>
    </html>

  11. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    13 Feb 2013 in reply to Basem
    Link to this post

    Powertools Root templates what you need?

     https://github.com/Sitefinity/PowerTools 

  12. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    12 May 2013
    Link to this post
    Any updates so far? Is this possible to define Layouts with Razor in Sitefinity? If yes are there any examples?
  13. Marin Atanasov
    Marin Atanasov avatar
    62 posts
    Registered:
    24 Sep 2012
    15 May 2013
    Link to this post
    Hello Denis,

    If you wish to use pure MVC, you can change the Default front-end MVC root template using PowerTools Root templates. We do not have any plans to add this functionality as a build-in feature at this point.

    If you are using hybrid mode, you can use a web forms master page as the base for your page template and still use MVC widgets inside it.

    Please let me know if I can be of further assistance.

    Regards,
    Marin Atanasov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  14. Natalya
    Natalya avatar
    4 posts
    Registered:
    04 Oct 2013
    04 Nov 2013 in reply to Marin Atanasov
    Link to this post
    Hi Marin,

    I'm trying to use https://github.com/Sitefinity/PowerTools/wiki/Root-Templates (for replacing pure MVC root template) and have an error (see log below) when trying to load page based on my Pure MVC template.
    ----------------------------------
    Timestamp: 11/4/2013 7:58:34 AM

    Message: HandlingInstanceID: f33e1d97-9ade-4105-921e-cfbc3212507f
    An exception of type 'System.NullReferenceException' occurred and was caught.
    -----------------------------------------------------------------------------
    11/04/2013 14:58:34
    Type : System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message : Object reference not set to an instance of an object.
    Source : Telerik.Sitefinity
    Help link : 
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void handler_PreRenderComplete(System.Object, System.EventArgs)
    Stack Trace :    at Telerik.Sitefinity.Web.PageRouteHandler.handler_PreRenderComplete(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Additional Info:

    MachineName : NIGU-PC
    TimeStamp : 11/4/2013 7:58:34 AM
    FullName : Telerik.Sitefinity.Utilities, Version=6.1.4600.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
    AppDomainName : 594390db-1-130280234712376966
    ThreadIdentity
    WindowsIdentity : Nigu-PC\Nigu
    Requested URL : http://localhost:60876/purepanel


    Category: ErrorLog

    Priority: 0

    EventId: 90000

    Severity: Error

    Title:Enterprise Library Exception Handling

    Machine: NIGU-PC

    App Domain: 594390db-1-130280234712376966

    ProcessId: 7804

    Process Name: C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer40.exe

    Thread Name: 

    Win32 ThreadId:6556

    Extended Properties: 
    ----------------------------------------
    ----------------------------------------

    How can I fix this error?

    Thanks,
    Natalya
  15. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    06 Dec 2016
    07 Nov 2013
    Link to this post
    Hi,

     I have tested and reproduced the problem, I have submitted the issue in github as power tools is open source project, here is the link for the issue.

    Regards,
    Stanislav Velikov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  16. Dave
    Dave avatar
    2 posts
    Registered:
    01 Oct 2012
    24 Dec 2013 in reply to Natalya
    Link to this post
    Hi Natalya,

    I don't know if you managed to fix this error but I got the same error when trying to use PowerTools to change the front-end MVC template in Sitefinity 6.2.  I found out that the problem is that the template now needs a runat="server" attribute in the head and the title tag removed as the title is now inserted this way.  E.g:

    <!DOCTYPE html>
    <html>
        <head runat="server">
            <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        </head>
        <body>
            <div class="sfPublicWrapper" id="PublicWrapper">
            </div>
        </body>
    </html>
  17. Thanh
    Thanh avatar
    13 posts
    Registered:
    21 Nov 2011
    26 Dec 2013 in reply to Stanislav Velikov
    Link to this post
    Can you help me in this post http://www.sitefinity.com/developer-network/forums/ecommerce/fields-of-product-does-not-support-unicode-for-label? I'm so sorry for posting here because I can't find any way to assign my post to Telerik Admin in this forum.
17 posts, 0 answered