4

I am trying a very simple contentpage at ~/View.cshtml that consists of

@inherits ViewPage
    @{
       Layout = "SimpleLayout";
       ViewBag.Title = "Title";
}
<div id="content-page">
<p>Test</p>
</div>

at ~/Views/Shared/SimpleLayout.cshtml is

<!DOCTYPE HTML>
<html>
<head>
    <title>Simple Layout</title>
</head>
<body>
 <div id="content">
     @RenderBody()
 </div>
</body>
</html>

In debug mode it works fine, but on deploy it then shows

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0146: Circular base class dependency involving 'RazorOutput.ViewPage' and 'RazorOutput.ViewPage'

I'm trying to follow the RockStars example as closely as possible, so don't have an idea of what's wrong. My service views work fine.

Any suggestions would be appreciated.

Update

When the name of the page is changed (e.g. NewPage.cshtml) then it will not work in Debug either, throwing the same exception.

4

3 回答 3

2

In Web.Config, make sure that you have:

<compilation debug="false">

I was getting the same error, and this fixed it.

于 2013-03-19T05:00:13.843 回答
2

Setting compilation debug="false" as suggested above did not work for me.

I was having the same error running locally in IIS Express and found that if I added this to the web.config it would work:

<appSettings>
  <add key="webPages:Enabled" value="false" />
</appSettings>

I found that setting in ServiceStack's RazorRockstar sample, after comparing it line by line with my own project to see why mine wasn't working.

于 2013-04-29T18:02:25.133 回答
1

I was receiving similar compilation errors when trying to render Razor pages. Check that your website's AppHost is inheriting from AppHostBase and not AppHostHttpListenerBase.

于 2013-03-15T17:47:43.590 回答