I am currently having some issues getting the ServiceStack Razor to render my page at the root of the site. I am encountering the following error
Compiler Error Message: CS0246: The type or namespace name 'ViewPage' could not be found (are you missing a using directive or an assembly reference?) public class @__CompiledTemplate : ViewPage {
I just started on the site and here are the contents of the web.config and the razor pages
Here is the web.config file at the root of the website
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 (and above?) -->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="FERNSWeb" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
Here is the default.cshtml file at the root of the site
@inherits ViewPage
This is the body
and the _Layout.cshtml at the root of the site
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FERNS - @ViewBag.Title</title>
</head>
<body>
@RenderBody()
</body>
</html>
The intellisense does not colorize the "ViewPage" entry in the "@inherits ViewPage" line in the default.cshtml And when i change the line to "@inherits ServiceStack.Razor.ViewPage", intellisense colorizes the ViewPage entry, but I get a exception this time and not a compilation error.
Exception Details: System.InvalidCastException: Unable to cast object of type 'Razor.__CompiledTemplate' to type 'System.Web.IHttpHandler'.
[InvalidCastException: Unable to cast object of type 'Razor.__CompiledTemplate' to type 'System.Web.IHttpHandler'.] System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) +56 System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +264 System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +89 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
The weird part is, if i move the Default.cshtml and the _Layout.cshtml file a Views folder I created for testing, the page renders just fine under the "/views" url. The Views folder does not have a web.config file in it.