This project is read-only.

Does "the renderpage method calls in generated output" call the generated output in partial view?

Jul 30, 2012 at 1:47 PM

I used razorgenerator with the input below..





 and output is ...




I wonder if the renderpage method in the output processes the view in the precompiled view?


Jul 30, 2012 at 1:55 PM

Yes, if the _LogIn view is precompiled and you have the engine installed, it should be using that.

Jul 30, 2012 at 2:14 PM

if view filename starting with underscore , classname is without underscore.Does partial view named starting with underscore "_" cause a problem?

Jul 30, 2012 at 4:26 PM

Not really. We simply strip the underscore to avoid compilation warnings. But the lookup depends on the original name of the file. If you look at the compiled file, the generated type should have an attribute that says what the virtual path of the file is.

Jul 31, 2012 at 1:31 PM

I run the razorgenerator custom tool on _ViewStart.cshtml, and the error below occured.. Do I have to exclude that file?


System.InvalidCastException: Unable to cast object of type myproject.Web.View.Views.ViewStart' to type 'System.Web.WebPages.StartPage'.

at System.Web.WebPages.StartPage.GetStartPage(WebPageRenderingBase page, String fileName, IEnumerable`1 supportedExtensions)

at CopyTaste.RazorGenerator.PrecompiledMvcView.Render(ViewContext viewContext, TextWriter writer) in c:\myproject.RazorGenerator\PrecompiledMvcView.cs:line 67

at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)


..line 67...










startPage =

StartPage.GetStartPage(webViewPage, "_ViewStart"

, ViewStartFileExtensions);


Jul 31, 2012 at 1:40 PM

What does your generated ViewStart class look like? It should look like this, where it extends ViewStartPage (which would make the cast work).

Jul 31, 2012 at 1:44 PM

Solved when I changed the base class of _ViewStart.cshtml output from WebViewPage to ViewStartPage. Odd..ViewStart must be derived from ViewStartPage..I think RazorGenerator must handle it..Is it true?

Jul 31, 2012 at 1:46 PM










GeneratedCodeAttribute("CustomRazorGenerator", ""








public class ViewStart : System.Web.Mvc.











public override void







1 "..\..\Views\_ViewStart.cshtml"














Jul 31, 2012 at 2:09 PM

The seems to imply that RazorGenerator is not treating your ViewStart page as a start page, and instead treats it as a regular view.

Do you see this if you start from a clean MVC project (internet app) and turn on RazorGenerator on all views? Or does it only happen with your specific project? If the latter, please try to isolate what might be different there.

Jul 31, 2012 at 2:24 PM

with nuget razorgeneratotor version, it works ..but custom razorgenerator tool with some changes does not work changes are minor for minification, what might cause it?

Jul 31, 2012 at 3:31 PM

Is RazorGenerator 1.4.3 compatible with VS2010?

Jul 31, 2012 at 4:51 PM

Yes, 1.4.3 should work fine with both VS2010 and VS2012. If you're only having problem with your custom modified build, then you're probably going to have to debug it to see what's going on. But if you can use the official build, it's obviously simpler! :)

Aug 1, 2012 at 9:11 AM

I debugged the core project..The code below sets the base type properly, but the generated code does not contain it as base type for _ViewStart.html!


public MvcCodeGenerator(string className, string baseClass, string rootNamespaceName, string sourceFileName, RazorEngineHost




(className, rootNamespaceName, sourceFileName, host)









baseType =







baseType = baseClass +

'<' + DefaultModelTypeName + '>'






private bool IsSpecialPage(string




string fileName = Path



return fileName.Equals(ViewStartFileName, StringComparison




private void SetBaseType(string




var baseType = new CodeTypeReference





Aug 1, 2012 at 12:49 PM

Thank you so much..Solved with custom mvc code generator.. and setbasetype moved into it..