MVC-only pages & page headers

Posted by Community Admin on 03-Aug-2018 14:05

MVC-only pages & page headers

All Replies

Posted by Community Admin on 28-Aug-2012 00:00

I am looking at moving our content over to MVC-only pages mostly to use the Kendou UI MVC tools that we purchased.  The biggest problem that I cannot find a solution for is being able to modify the <head> section of a MVC-only page.  It seems that for these "pure" type of pages, Sitefinity is ignoring the "HTML included in the <head> tag (except title, keywords, description)" section in Page Title and Properties.  (I hope that this is a bug that will be fixed.)

Digging around the Telerik.Sitefinity.dll file I think that MVC-only pages are rendered using the Telerik.Sitefinity.Mvc.Rendering.PureMvcPageResolver() class.  There is a string in there called DefaultFrontendPageTemplate that points to an aspx page that I think is the basis for all MVC only pages.  The file is called "Telerik.Sitefinity.Resources.Pages.FrontendMvc.aspx and is embedded in the Telerik.Sitefinity.Resources.dll file.  Is there a way to override that string to point to a custom aspx page that can essentially serve as a master page for MVC-only pages?

I considered MVC Layouts but I cannot find a way to modify the <head> section of the rendered page because the MVC widgets are rendered later in the page life cycle after the head tag has been created.

Posted by Community Admin on 29-Aug-2012 00:00

Hello Mike,

This is a known issue. You cannot add anything to the <head> tag in a Pure MVC page for the time being. You currently cannot change the DefaultFrontendPageTemplate either.

There is a solution planned for 5.2 that will let you include HTML in the <head> tag by using a section.

We are sorry for the caused inconvenience.

Kind 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 18-Oct-2012 00:00

Marin,

I see that 5.2 has been released however the change log does not mention any changes the Sitefinity implementation of MVC.  Did this fix make it into the 5.2 build of Sitefinity?  If not, I really need a workaround to be able to modify the <head> tag of an MVC only page template.

Posted by Community Admin on 22-Oct-2012 00:00

Hello  Mike,

We could not get this feature ready for the release but it will be included in the service pack.

We are terribly sorry for any inconvenience that this delay might cause you.

Kind 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 12-Jun-2013 00:00

was this ever completed in any existing release?

Posted by Community Admin on 19-Jun-2013 00:00

Hi,

We have fixed the problem and the fix will be included in our upcoming release Sitefinity 6.1. Fixing the problem required more development time, because we have another problem that was preventing this fix. Please excuse us for the inconvenience. Note that we haven't tested to place HTML in the head sections of the views, it is only tested if you place some code in Title and properties section of pages.

Regards,
Stefani Tacheva
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 12-Aug-2013 00:00

Hi,

I thought it is possible already for a while with PowerTools?

Although, I still don't sure hot to setup page title on pure MVC mode.
If I use ViewBag.Title in my view PureMvcPageResolver throws "null reference" exception and I get YSOD. Can someone from Sitefinity confirm what is the way to set page title in MVC mode only????

Thanks!

Posted by Community Admin on 12-Aug-2013 00:00

the power tools let you access and modify a layout template, but unless something has changed recently, they do not allow you to add Sections for rendering custom html or javascript.

I checked the release notes for 6.1 and SP1 and don't see anything related to this. was this indeed released?

Posted by Community Admin on 12-Aug-2013 00:00

Can you please elaborate what is the issue? Maybe it is Monday and my head is "slow".
By modifying root template you can specify whatever code you want on head and other places. Reference your custom JS or CSS. Or you mean something that should be resolved on server side? Like <% Whatever.RenderMyCustomCode() %>???

Posted by Community Admin on 12-Aug-2013 00:00

what i'm referring to is pure MVC. if you create an MVC widget and attempt to have this widget render CSS or JS references in the master layout template as a Section, they do not work and nothing is rendered. I believe it works in Hybrid mode, but not pure mvc.

Posted by Community Admin on 12-Aug-2013 00:00

Ah-hah, I see now. Yeah that would be a great if Sitefinity will support that. I join to this request!
So far as a workaround I use combined CSS file that contains everything necessary in it.
As for JS files, you still can include them in widget's view but it will be in the page's body (where widget is rendered).

Posted by Community Admin on 15-Aug-2013 00:00

Hi Mike,

The Sitefinity power tools allow you to create a root template and put your scripts there. The basic idea is to implement the IRootTemplateResolver class in your custom Resolver class and return the path to a template file. If you register your custom class on the Application_Start event in the Global.asax file it will act as a layout to your MVC views. Here is an example:
https://github.com/Sitefinity/PowerTools/tree/master/Examples

If you have more questions, please feel free to contact us.

Regards,
Tosho Toshev
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 04-Nov-2013 00:00

Hi Tosho,

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

Hello,

 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

This thread is closed