0

Im using signaturepad from Nuget, everything is fine with the exception of trying to recreate signatures from the byte array stored on the server.

My Model has

public byte[] MySignature { get; set; }

and in my index view I have this to try and display the signature, but all I ever get is invalid urls

<td>
        @{
            if (item.MySignature != null)
            {
                <img src="@string.Format("data:image/jpeg;base64,{0}", Convert.ToBase64String(item.MySignature));" />
            }
        }
</td>

Am I missing something plainly obvious?

2
  • Not quite sure if it's your problem, but the semicolon ; is not necessary at the end. Commented Mar 2, 2017 at 21:13
  • You sir, are a legend. Originally I put it altogether in multiple lines and the ; was just left over from a copy paste. Worked like a charm. If you wanna add an answer I'll mark it. Commented Mar 2, 2017 at 22:11

1 Answer 1

1

Turns out my guess was right :)

The semicolon at the end of the src attribute value was superfluous:

<img src="@string.Format("data:image/jpeg;base64,{0}", Convert.ToBase64String(item.MySignature));" />

It must be:

<img src="@string.Format("data:image/jpeg;base64,{0}", Convert.ToBase64String(item.MySignature))" />

The reason is that the first one includes the semicolon in the base-64 string, which makes it invalid.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.