Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • tarek 9 posts 30 karma points
    May 10, 2011 @ 09:57
    tarek
    1

    Error loading Razor Script

    Hi,  when i try to use Razor Macro

    <umbraco:Macro runat="server" language="cshtml">
    <
    h4>Hello World</h4>
    </
    umbraco:Macro>

    I get an error

    This is the error:

    Error loading Razor Script
    c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ce3443bb\58e618b\App_Web_inline-71cf33f09db3dfcc7669a3e4c8583d52.cshtml.ae9e2569.9k1svgrr.0.cs(19): error CS0234: Le type ou le nom d'espace de noms 'Helpers' n'existe pas dans l'espace de noms 'System.Web' (une référence d'assembly est-elle manquante ?)

    (it's french, it say that the namespace Helpers dont exists in System.Web), but I have the namespace Helpers and all namespaces of .NET 4 without any problem.

    when I write it without Razor Macro, I get the Hello World

    <h4>Hello World</h4>
  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 16, 2011 @ 14:07
    Sebastiaan Janssen
    0

    Do you have MVC2 and MVC3 installed? I seem to recall that you would need them both.

  • woo123 3 posts 24 karma points
    Jun 01, 2011 @ 15:54
    woo123
    1

    Hah I'm solving same issue  (for second day..).

    insert this into your web.config, section assemblies:

    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

    I get rid of this dependency, but there is another I dont know how to solve - so if somebody could help with this error:

    The type or namespace name 'Web' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

    Then it will be great.

    Why inline Razors scripts needs to have assemblies defined in webconfig if umbraco is build from 4.7.1 source branch? When I run umbraco from 4.7.0 binaries it is working fine and there is not needed to modify web.config.

     

    Thanks

     

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jun 22, 2011 @ 20:13
    Sebastiaan Janssen
    0

    That looks pretty messed up, I would suggest you have a good hard look at your web.config versus the one that comes with Umbraco, some stuff seems to be missing there.

  • João Pereira 41 posts 64 karma points
    Jun 23, 2011 @ 17:50
    João Pereira
    3

    Hi there,

    Just stumped in the same error and just sharing how I overcome it.

    I added the web.config line (<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />) just as woo123 wrote, but still got the following error:

     

    c:\Users\Joao\AppData\Local\Temp\Temporary ASP.NET Files\root\42fd127e\8bb72002\App_Web_634444441819238282_listposts.cshtml.70df5e80.s4lfi-yx.0.cs(23): error CS0234: The type or namespace name 'Html' does not exist in the namespace 'System.Web.WebPages' (are you missing an assembly reference?) 

     

    As the error implies, a reference to the System.Web.WebPages is required. So to be allowed to use and save Razor files in Umbraco Admin, just had the following 2 lines:

            <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

     

    I believe that this error occurs when we install and run Umbraco without MVC3 installed. After the MVC3 installation, the error persists. Add the 2 lines under Compilation->Assemblies and everything should be fine.

    More info here (http://www.asp.net/learn/whitepapers/mvc3-release-notes#upgrading)

  • Murray Roke 503 posts 966 karma points c-trib
    Jul 07, 2011 @ 08:02
    Murray Roke
    0

    Thanks João and woo123 That's awesome, fixed it for me

    Just another piece to the puzzle:

    I had a separate .cshtml file which was working perfectly until I tried to use inline cshtml macro, at which point everything broke permanently. even removing all inline cshtml did not resolve the issue. But João's solution has it working again. thanks!

    (oh also if you don't have syntax highlighting and autocomplete working make sure you reference Microsoft.CSharp in your project.)

  • Olie 11 posts 52 karma points
    Jul 07, 2011 @ 23:11
    Olie
    0

    Thanks... This fixed it for me too!

  • antao 81 posts 371 karma points
    Jan 11, 2012 @ 17:15
    antao
    0

    Thanks João, it also fixed my problem.

  • Esben Sune Rasmussen 3 posts 23 karma points
    Oct 08, 2012 @ 11:24
    Esben Sune Rasmussen
    0

    We had a project where we are not using MVC, but did wan't to use Razor for our macro script, this was one of the issues we also discovered.

    Our solution was to add http://nuget.org/packages/Microsoft.AspNet.WebPages to our project, that way we had the right dependencies and could push these to our src repo.

    But thanks for the excellent pointers, it helped narrow down the issue :-)

Please Sign in or register to post replies

Write your reply to:

Draft