From: | Rick Strahl |
To: | Richard Norris |
You'll definitely want to use that rather than the code posted with the article whcih is pretty old. I've been meaning to update this at some point but I just can't find the time.
The GitHub code has tons of examples and quite a few sample tests that should be useful in figuring out how to use it.
+++ Rick ---
Hi Rick,
Many thanks for your reply.
I'm not sure about the version, I never downloaded the source from GitHub, I guess this is my next step.
I'll go and download that and read the documentation and see where I get.
Many Thanks
Regards
Richard
Are you using the latest version of tihs stuff from GitHub? If not go grab that...
https://github.com/RickStrahl/Westwind.RazorHosting
I think the problem is the dependencies of System.Web.Razor - you need to make sure the right version is used which requires some additional configuration entries. The samples in the GitHub code should have the correct dependencies.
As to dependencies - look at the dependencies in the Westwind.RazorHosting assembly. One of those is probably required as well.
+++ Rick ---
Hi all,
I'm following Rick's fantastic article on Razor hosting and I love the work he has put into supporting the use of it more appropriately. I've included the project in one of my solutions in an attempt to use the StringHostContainer to render my templates. It all seems to work like a charm apart from the fact I am struggling with getting the intelli-sense to work with the templates.
I managed to get some of the intelli-sense working by adding a web.config file. I am able to reference an external assembly of mine and the intelli-sense can see the CustomContext OK now but without the inherits statement which means it doesn't know what Context is. The problem is I cannot the IDE to load and see the RazorHosting assembly in order to see this, trying to include the namespace results in an IDE warning. The IDE complains about not being able to find or load it or one of its dependencies. I checked I included the RazorHosting assembly in the project and made it copy local, then I added the System.Web.Razor assembly and did the same but then the error for the RazorHosting assembly changed to the System.Web.Razor assembly instead. What are its dependencies? What do I need in my web.config file? I just don't know? Below is my web.config, it is essentially thrown together, I have no idea how MVC stuff should be configured, I've hacked in the assembly references (not full names) is this my problem? I'm assuming I am missing other assembly references from this file and my project. Here is the web config:
<?xmlversion="1.0"?><configuration><configSections><sectionGroupname="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"><sectionname="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /><sectionname="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /></sectionGroup></configSections><system.web.webPages.razor><host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /><pages pageBaseType="System.Web.Mvc.WebViewPage"><namespaces><add namespace="System.Web.Mvc" /><add namespace="System.Web.Mvc.Ajax" /><add namespace="System.Web.Mvc.Html" /><add namespace="System.Web.Routing" /><add namespace="RazorHosting" /><add namespace="InternalResourceHttpServer" /></namespaces></pages></system.web.webPages.razor><system.web><compilation targetFramework="4.0"><assemblies><add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /><add assembly ="System.Web.Razor" /><add assembly="RazorHosting" /><add assembly="InternalResourceHttpServer" /></assemblies></compilation></system.web></configuration>
Here are my project references:
InternalResourceHttpServer
Microsoft.CSharp
RazorHosting
System
System.Core
System.Data
System.Data.DataSetExtensions
System.Web.Razor
System.Xml
System.Xml.Linq
Just going over this now, I'm certain I'm missing some ASP.NET assemblies here, just not sure which ones? Its not critical to have the intellisense as the templates appear to work but it would be nice to have it functioning correctly. Any advice would be greatly appreciated.
TIA
Richard
West Wind Technologies
Making waves on the Web