aspnet / Mvc

[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CompilationFailedException for cshtml files over 20MB

Blastnsmash opened this issue · comments

Is this a Bug or Feature request?:

I dont know - it may be intended but hoping for an override?

Steps to reproduce (preferably a link to a GitHub repo with a repro project):

Serve up a cshtml page that's over 20MB in size

Description of the problem:

Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: 'One or more compilation failures occurred:
error CS8103: Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals.'

Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:

2.1.3

commented

Thanks for contacting us, @Blastnsmash.
Can you give us more information regarding your scenario. It's unclear what you're trying to do.

I have SVG elements in a couple of web pages that make the file slightly over 20MB. There are some files that have the same type of SVG elements but are around 17MB and they work fine.

All I"m trying to do is serve up the page:

   public ActionResult Get()
        { 
            return View("~/LargeFile.cshtml");
        }
commented

@Blastnsmash, the error you're seeing is a limitation in Roslyn. You can work around that by trying to split your view content into multiple Views. A sample project with a repro would allow us to give you a better guidance.

Is it possible to tell MVC to specifically not process certain elements on the page? For example, most of the content is actually static content and should be ignored. Namely all the svg elements.

commented

@Blastnsmash, can you host a similar file (cshtml) in GitHub or just share the portion of it here with some comments instead of huge SVG conent so we can see what it looks like?

commented

Hi. We're closing this issue as we have heard no response from you for some time now. If you have more details and are encountering this issue please add a new reply and re-open the issue.

Thanks for the suggestion, breaking up the document into either partial views or view components works just fine - it also helps Visual Studio handle large documents. I apologize for the delay. Thanks again.