Script.Include("XXX").AtHead() is not rendered

Topics: Writing modules
Sep 7, 2012 at 3:03 PM

Hello guys,

 

I have the following issue. I need to render a custom view from a controller. The controller method looks as follows:

 

public ActionResult ShowConsult(int consultId)
{
     //...
     return View("ShowConsult");
}

ShowConsult is a view manually added by me. The view contains the following:

<!DOCTYPE html>
<html lang="en-US" class="static contents">
<head>
    <meta charset="utf-8" />

    <title>MyTitle</title>
   
    @{
        Style.Include("file1.css");
        Style.Include("file2.css");
        Script.Include("script1.js").AtHead();

// etc
}


</body>
</html>

When rendering the file, I can view the html content of the view, but the references to any css or js file are not rendered. I was expected to have something like:

 <link href="./Modules/KloudBase.QuTorial/Styles/style1.css" rel="stylesheet" type="text/css" />
 <link href="./Modules/KloudBase.InConsult/Styles/style2.css" rel="stylesheet" type="text/css" />

But there is nothing rendered.

 

Would you please assist me with this issue? What am I doing wrong?

Coordinator
Sep 12, 2012 at 6:38 PM
Edited Sep 12, 2012 at 6:39 PM

Sure, you've pretty much destroyed document.cshtml here. Try to compare your file with the original one and you'll see that you removed the zone that is used to render the head scripts.