Search code examples
c#asp.net-core

ASP Core 3.1 Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals


I'm using Visual Studio 2019 and I have 5 or more areas in my ASP.NET Core MVC application.

When I was about to create a new controller and new razor (.cshtml file) with dynamic layouts, menus, header and footer, I got the error shown below.

I see a lot of questions that don't have answers.

enter image description here


Solution

  • I just found out the answer by editing the .CSPROJ file and add the following :

    <PropertyGroup><TargetFramework>netcoreapp2.1</TargetFramework> 
    <RazorCompileOnBuild>false</RazorCompileOnBuild> 
    <RazorCompileOnPublish>true</RazorCompileOnPublish></PropertyGroup>
    

    and this one:

    <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <RazorCompileOnBuild>false</RazorCompileOnBuild>
    <RazorCompileOnPublish>true</RazorCompileOnPublish>
    </PropertyGroup>