Using MVC

Posted by Community Admin on 04-Aug-2018 03:10

Using MVC

All Replies

Posted by Community Admin on 26-Jul-2012 00:00
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
Posted by Community Admin on 26-Jul-2012 00:00
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!
Posted by Community Admin on 26-Jul-2012 00:00
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.
Posted by Community Admin on 26-Jul-2012 00:00
www.pluralsight-training.net is the best. Its not free, but I have learned so much about MVC there.
Posted by Community Admin on 26-Jul-2012 00:00
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!
Posted by Community Admin on 26-Jul-2012 00:00
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 
Posted by Community Admin on 26-Jul-2012 00:00
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
Posted by Community Admin on 27-Jul-2012 00:00
@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.
Posted by Community Admin on 27-Jul-2012 00:00
@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.
Posted by Community Admin on 13-Feb-2013 00:00

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>

Posted by Community Admin on 13-Feb-2013 00:00

Powertools Root templates what you need?

 github.com/.../PowerTools 

Posted by Community Admin on 12-May-2013 00:00
Any updates so far? Is this possible to define Layouts with Razor in Sitefinity? If yes are there any examples?
Posted by Community Admin on 15-May-2013 00:00
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
Posted by Community Admin on 04-Nov-2013 00:00
Hi Marin,

I'm trying to use github.com/.../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 : 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
Posted by Community Admin on 07-Nov-2013 00:00
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
Posted by Community Admin on 24-Dec-2013 00:00
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>
Posted by Community Admin on 26-Dec-2013 00:00
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.
This thread is closed