Validate Base64 Image in ASP.Net / C# -


i'm building asp.net mvc4 application allows user send image encoded base64 string via post request. how validate user input ensure base64 string indeed image , prevent user passing malicious data in post request? e.g. prevent external urls being injected.

i found this , this tells in php not asp.net/c#.

i follow same approach in php example , try create image base64 encoded data. if data not valid image, expect image throw exception or @ least, null.

doing quick search, found example here on so shows several methods create image base64 encoded string.

assuming ms of type memorystream, suspect wrap either 1 of these methods try/catch:

new bitmap(ms) 

or

mage.fromstream(ms); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -