The file "~/Areas/Admin/Views/Shared/_Login.cshtml" could not be rendered, because it does not exist or is not a valid page.

Mar 15, 2013 at 5:53 AM
I'm having my administration area in a seperate project, but when I run the app I get the error saying :

The file "~/Areas/Admin/Views/Shared/_Login.cshtml" could not be rendered, because it does not exist or is not a valid page.

Is this because I can not pre-compile template files?

/Martin
Mar 15, 2013 at 7:49 AM
I forgot to show you the code from the layout file, it is as follows :
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/reset.css" rel="stylesheet" />
    <link href="~/Content/AdminLogin.css" rel="stylesheet" />
    <title>@ViewBag.Title</title>
</head>
<body>
    <div id="wrapper">
        <div id="logo"></div>
        <div id="splitter"></div>
        <div id="loginform">
            <div id="formTop"></div>
            <div id="formMiddle">
                <div id="formInner">
                    @RenderBody()
                </div>
            </div>
            <div id="formBottom"></div>
        </div>
    </div>
</body>
</html>
Note : If I place the file in my host application, it all works just fine.

/Martin
Coordinator
Mar 15, 2013 at 5:30 PM
Did you add the NuGet package to that other project? Also, did you verify that the code is correctly getting generated under the .cshtml file?
Mar 15, 2013 at 8:11 PM
Should I add it to my main app too?

And yes the .cs file gets generated :
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.18034
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Cms.Admin.Areas.Admin.Views.Shared
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Web;
    using System.Web.Helpers;
    using System.Web.Mvc;
    using System.Web.Mvc.Ajax;
    using System.Web.Mvc.Html;
    using System.Web.Optimization;
    using System.Web.Routing;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.WebPages;
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.4.0")]
    [System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Admin/Views/Shared/_Login.cshtml")]
    public partial class Login : System.Web.Mvc.WebViewPage<dynamic>
    {
        public Login()
        {
        }
        public override void Execute()
        {
WriteLiteral("<!DOCTYPE html>\r\n\r\n<html>\r\n<head>\r\n    <meta");

WriteLiteral(" name=\"viewport\"");

WriteLiteral(" content=\"width=device-width\"");

WriteLiteral(" />\r\n    <link");

WriteAttribute("href", Tuple.Create(" href=\"", 103), Tuple.Create("\"", 129)
, Tuple.Create(Tuple.Create("", 110), Tuple.Create<System.Object, System.Int32>(Href("~/Content/reset.css")
, 110), false)
);

WriteLiteral(" rel=\"stylesheet\"");

WriteLiteral(" />\r\n    <link");

WriteAttribute("href", Tuple.Create(" href=\"", 161), Tuple.Create("\"", 192)
, Tuple.Create(Tuple.Create("", 168), Tuple.Create<System.Object, System.Int32>(Href("~/Content/AdminLogin.css")
, 168), false)
);

WriteLiteral(" rel=\"stylesheet\"");

WriteLiteral(" />\r\n    <title>");

            
            #line 8 "..\..\Areas\Admin\Views\Shared\_Login.cshtml"
      Write(ViewBag.Title);

            
            #line default
            #line hidden
WriteLiteral("</title>\r\n</head>\r\n<body>\r\n    <div");

WriteLiteral(" id=\"wrapper\"");

WriteLiteral(">\r\n        <div");

WriteLiteral(" id=\"logo\"");

WriteLiteral("></div>\r\n        <div");

WriteLiteral(" id=\"splitter\"");

WriteLiteral("></div>\r\n        <div");

WriteLiteral(" id=\"loginform\"");

WriteLiteral(">\r\n            <div");

WriteLiteral(" id=\"formTop\"");

WriteLiteral("></div>\r\n            <div");

WriteLiteral(" id=\"formMiddle\"");

WriteLiteral(">\r\n                <div");

WriteLiteral(" id=\"formInner\"");

WriteLiteral(">\r\n");

WriteLiteral("                    ");

            
            #line 18 "..\..\Areas\Admin\Views\Shared\_Login.cshtml"
               Write(RenderBody());

            
            #line default
            #line hidden
WriteLiteral("\r\n                </div>\r\n            </div>\r\n            <div");

WriteLiteral(" id=\"formBottom\"");

WriteLiteral("></div>\r\n        </div>\r\n    </div>\r\n</body>\r\n</html>\r\n");

        }
    }
}
#pragma warning restore 1591
Coordinator
Mar 15, 2013 at 9:28 PM
Only the project that uses RazorGenerator needs the package. Please look at my test app, which uses a separate project and works fine. First, verify that it works for you, and then maybe you can spot some differences with yours?
Mar 16, 2013 at 4:28 PM
I did try your app and it works just fine. I ended up deleting my two app's to have some fresh code to work with and it seems to work now.

Another question thoug, is it posible to have css, scripts, images ect in the app referencing RazorGenerator and use them in the compiled views?

/Martin
Coordinator
Mar 16, 2013 at 4:40 PM
No, it doesn't support static files at this point. See http://razorgenerator.codeplex.com/workitem/12
Mar 18, 2013 at 6:02 AM
Would I then have to place my scripts, styles and images in the host app?
Coordinator
Mar 18, 2013 at 4:12 PM
At this point that would probably be the simplest solution.