Is there a way to detect if an HTML page contains any razor/C# code? Essentially I want users to be able to provide custom layouts, with tags that I will replace with RenderSection. I want to validate that prior to making this replacement, that none of the HTML contains anything like for example, <a href="@(some C# code)".
All discussions about alternative ways to do this, should/could/would aside, just simply: Is there a way to programmatically detect if a file contains C#/Razor code?
.htmlfiles, instead of accepting.cshtmlfiles? I don't think ASP.NET MVC will allow Razor code in HTML-only files.@section's from the view. It seems the easiest way to do this is just replace the magic tags withRenderSectionand then set the page as the layout. This will leverage the existing layout engine nicely, and avoid me re-inventing the wheel. To make it safe, I want to neuter the page of C#, before adding RenderSection.