YAFLogo

paulc
  • paulc
  • 50.2% (Neutral)
  • YAF Forumling Topic Starter
11 years ago
Hi

I have been trying to integrate YAF into an mvc web application. I have created an mvc4 website template and added YAF to a sub folder. This runs ok from the default.aspx that comes with the forum. When i try to create an mvc content page using an aspx master page I get problems relating to the CSS classes.

if or Styles.Render("~/Content/css") is included in the master page then the YAF CSS throws an exception :

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]

System.Web.UI.ControlCollection.Add(Control child) +9600971

YAF.Core.Services.PageElementRegister.RegisterCssInclude(Control element, String cssUrl) +116

YAF.Core.Services.PageElementRegister.RegisterCssIncludeResource(String cssUrlResource) +110

YAF.Modules.PopupDialogNotification.OnPreRender(EventArgs e) +391

System.Web.UI.Control.PreRenderRecursiveInternal() +83

System.Web.UI.Control.PreRenderRecursiveInternal() +168

System.Web.UI.Control.PreRenderRecursiveInternal() +168

System.Web.UI.Control.PreRenderRecursiveInternal() +168

System.Web.UI.Control.PreRenderRecursiveInternal() +168

System.Web.UI.Control.PreRenderRecursiveInternal() +168

System.Web.UI.Control.PreRenderRecursiveInternal() +168

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

Ive looked into this but cant work out why this is happening. does anybody know why this is or how to get around this? If not is there another way to use YAF inside an mvs master page or layout.cshtml?

Thanks

Paul

Sponsor
JP
  • JP
  • 100% (Exalted)
  • YAF Leader
11 years ago
I've also tried... I am doing an MVC4 site with Razor views, but have not found a way to implement YAF fully into that... So I have resigned to using the YAF default.aspx with the header & footer html code from the _layout.cshtml...

I do however use the YAF Membership for the MVC4 site too...


He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Old Chinese Proverb]
paulc
  • paulc
  • 50.2% (Neutral)
  • YAF Forumling Topic Starter
11 years ago
hi

i found out this was because of the header section :

http://stackoverflow.com/questions/4995274/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blo 

i created a new project using an aspx master page and tried the workaround above and it worked. i havent tried in razor though.

how did you get the membership to work? i cant get it to work as mvc uses webmatrix.extendedMembershipProvidor instead of the Membership provider

Zero2Cool
  • Zero2Cool
  • 100% (Exalted)
  • YAF Leader YAF Version: YAF 3.1.16
11 years ago
I modified the ASP.NET Sample Application for my site with a page that displays YAF, but would much prefer to use MVC and Razor as well.