Skip to content

Instantly share code, notes, and snippets.

View GregorT's full-sized avatar

Gregor Trcek GregorT

View GitHub Profile
GregorT / JavascriptOutputAttribute.cs
Last active December 28, 2017 13:04
Converting IActionResult view to javascript file with custom ActionFilterAttribute in Asp.Net Core 2x
namespace yourApplicationNameSpace
public class JavascriptOutputAttribute : ActionFilterAttribute
private static readonly Regex OpenScriptTag = new Regex(@"^\s*<script[^>]*>", RegexOptions.Compiled);
private static readonly Regex CloseScriptTag = new Regex(@"</script>\s*$", RegexOptions.Compiled);
public override async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
var resp = context.HttpContext.Response;