Razor icon indicating copy to clipboard operation
Razor copied to clipboard

NotImplementedException on rendering attributes with non-latin letters added from IClientModelValidator

Open dubtar opened this issue 10 years ago • 2 comments

Implementing IClientModeValidator

    public class MyAttr: ValidationAttribute, IClientModelValidator  {
    ...
    public void AddValidation(ClientModelValidationContext context)
    {
        string message = "Привет!"; // message in Russian throws on render
        // string messge = "Test"; is rendered fine
        context.Attributes.Add("data-val-myval", message);
    }

Throws exception if message contains non-latin letters.

An unhandled exception occurred while processing the request.

NotImplementedException: The method or operation is not implemented.
Microsoft.AspNetCore.Razor.TagHelpers.DefaultTagHelperContent.EmptyOrWhiteSpaceWriter.Write(Char value)
System.Text.Encodings.Web.TextEncoder.Write(TextWriter output, Char* input, Int32 inputLength)
System.Text.Encodings.Web.TextEncoder.EncodeCore(TextWriter output, Char* value, Int32 valueLength)
System.Text.Encodings.Web.TextEncoder.Encode(TextWriter output, String value, Int32 startIndex, Int32 characterCount)
Microsoft.AspNetCore.Mvc.Rendering.TagBuilder.AppendAttributes(TextWriter writer, HtmlEncoder encoder)
Microsoft.AspNetCore.Mvc.Rendering.TagBuilder.WriteTo(TextWriter writer, HtmlEncoder encoder)
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewBuffer.WriteTo(TextWriter writer, HtmlEncoder encoder)
Microsoft.AspNetCore.Razor.TagHelpers.DefaultTagHelperContent.IsEmptyOrWhiteSpaceCore(Object entry, EmptyOrWhiteSpaceWriter writer)
Microsoft.AspNetCore.Razor.TagHelpers.DefaultTagHelperContent.get_IsEmptyOrWhiteSpace()
Microsoft.AspNetCore.Mvc.TagHelpers.LabelTagHelper.d__15.MoveNext()

dubtar avatar May 23 '16 16:05 dubtar

Both a bug and a test gap.

dougbu avatar May 23 '16 16:05 dougbu

44f0aa6

dougbu avatar Jun 01 '16 05:06 dougbu