.Net solution with muliple projects containing blocks and pageTypes


Hi all,

I'm trying to split up my project into multiple projects for reusage in different solutions.

/... some stuff in here

After including the dependencies and building the main optimizely project I can choose the pageTypes and or blocks, but then the views are not found:

InvalidOperationException: The view '/Modules/Pages/Standard/Views/StandardPage.cshtml' was not found. 
The following locations were searched: /Modules/Pages/Standard/Views/StandardPage.cshtml

The same happens, when placing the "image" block on a working page (not StandardPage)

InvalidOperationException: The view 'Components/ImageBlock//Modules/Blocks/Image/Views/index.cshtml' was not found. 
The following locations were searched:/Modules/Blocks/Image/Views/index.cshtml

There the "Components/ImageBlock" is added somehow.

Do I have to create some links inside myOptimizely project. This would destroy my modular solution.

Have a happy new Year

Jan 03, 2023 15:10


You need to add the assembly to the application parrts.

public void ConfigureServices(IServiceCollection services)
    var assembly = typeof(MySharedController).Assembly;

    services.Configure<MvcRazorRuntimeCompilationOptions>(options => 
    { options.FileProviders.Add(new EmbeddedFileProvider(assembly)); });
Jan 03, 2023 17:44

Thank you Mark,

Works like charm. I also had to add

        <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.1.6" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.0.0" />

to the project file main.csproj and the paths to the template-files in the shared.csproj. But thanks to the link I found these dependencies

Have a great 2023

Jan 04, 2023 8:31
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.