You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 19, 2018. It is now read-only.
The following extension method is a simplified version of the one we actually use, to demonstrate the issue.
public static HtmlString AddResource(this IHtmlHelper htmlHelper, Func<object, HelperResult> template)
{
using (var writer = new StringWriter(CultureInfo.InvariantCulture))
{
var content = template(null);
content.WriteTo(writer, HtmlEncoder.Default);
hash = writer.ToString().GetHashCode();
}
// TODO: do some stuff with the content
return new HtmlString(String.Empty);
}
In RC1 - I could use this within a razor view, such a a view for a ViewComponent, like so:
@Html.AddResource(
@<script type="text/javascript">
require(['jquery'], function (jquery) {
jquery(document).ready(function() {
// do some stuff
});
});
</script>
)
However in RC2, this line now throws a null ref exception:
content.WriteTo(writer, HtmlEncoder.Default);
I'm really not sure how this all sits together to begin with, any ideas what changed and how I can fix this method to work in RC2?