Click here to Skip to main content
15,894,825 members
Home / Discussions / C#
   

C#

 
GeneralRe: Missing data on Windows App form C# Pin
Gerry Schmitz7-Jun-17 3:16
mveGerry Schmitz7-Jun-17 3:16 
GeneralRe: Missing data on Windows App form C# Pin
Jochen Arndt7-Jun-17 3:26
professionalJochen Arndt7-Jun-17 3:26 
AnswerRe: Missing data on Windows App form C# Pin
Luc Pattyn8-Jun-17 13:44
sitebuilderLuc Pattyn8-Jun-17 13:44 
GeneralRe: Missing data on Windows App form C# Pin
Member 1313172611-Jun-17 20:41
Member 1313172611-Jun-17 20:41 
GeneralRe: Missing data on Windows App form C# Pin
Luc Pattyn12-Jun-17 6:15
sitebuilderLuc Pattyn12-Jun-17 6:15 
GeneralRe: Missing data on Windows App form C# Pin
Member 1313172612-Jun-17 20:39
Member 1313172612-Jun-17 20:39 
GeneralRe: Missing data on Windows App form C# Pin
Luc Pattyn12-Jun-17 23:42
sitebuilderLuc Pattyn12-Jun-17 23:42 
QuestionJson parser error when converting iphone images from bytes to base64 string in a MVC JsonResult Pin
jkirkerx6-Jun-17 10:22
professionaljkirkerx6-Jun-17 10:22 
So I'm storing some images in a file. I get the bytes, and convert the bytes to a Base64 string, that I place in a model that I return as Json.

At first everything was working fine with test images. Then I started using the customer images and pictures off my iPhone 6 and that's where the trouble began.
I get this parser error on the JQuery side, in which I isolated down to the Base64 string of the image.
So I have some bad chars that need to be formatted or converted.

I'm lost here ....
I have the replace statements that I added, but still get the error.
I think the pad right is not required.
I took the plain base64 string and pasted it into Best Online Base64 to Image converter and the image rendered fine.
I searched for JSON encoding, and got the replace chars.

Any point in the right direction would be appreciated.

picture.Base64 is a string
picture.Data is byte[]
public async Task<JsonResult> json_load_portfolio_picture(int PictureID, string PictureName)
{
      model_portfolio_image picture = io_portfolio_images.Load_Portfolio_Picture(PictureID);
      if (picture != null )
      {
          picture.Base64 = Convert.ToBase64String(picture.Data, 0, picture.Data.Length).Replace("/", "-").Replace("+", "_").Replace("=", "");
          picture.Base64 = picture.Base64.PadRight(picture.Base64.Length + (4 - picture.Base64.Length % 4) % 4, '=');
      }           

      await Task.Delay(1);
      return Json(picture, JsonRequestBehavior.AllowGet);
}
If it ain't broke don't fix it

AnswerRe: Json parser error when converting iphone images from bytes to base64 string in a MVC JsonResult [solved] Pin
jkirkerx6-Jun-17 12:49
professionaljkirkerx6-Jun-17 12:49 
SuggestionRe: Json parser error when converting iphone images from bytes to base64 string in a MVC JsonResult [solved] Pin
Richard Deeming7-Jun-17 0:57
mveRichard Deeming7-Jun-17 0:57 
GeneralRe: Json parser error when converting iphone images from bytes to base64 string in a MVC JsonResult [solved] Pin
jkirkerx7-Jun-17 6:33
professionaljkirkerx7-Jun-17 6:33 
QuestionCreate a chart in PowerPoint using C#. Pin
Member 126813284-Jun-17 22:30
Member 126813284-Jun-17 22:30 
AnswerRe: Create a chart in PowerPoint using C#. Pin
OriginalGriff4-Jun-17 22:43
mveOriginalGriff4-Jun-17 22:43 
Questioncustom controls not binding wpf Pin
Member 112967764-Jun-17 7:52
Member 112967764-Jun-17 7:52 
AnswerRe: custom controls not binding wpf Pin
Gerry Schmitz5-Jun-17 5:36
mveGerry Schmitz5-Jun-17 5:36 
GeneralRe: custom controls not binding wpf Pin
Member 112967765-Jun-17 18:30
Member 112967765-Jun-17 18:30 
QuestionConfigure Remote Machine's IP in C# Service At Install Time Pin
Django_Untaken3-Jun-17 22:58
Django_Untaken3-Jun-17 22:58 
AnswerRe: Configure Remote Machine's IP in C# Service At Install Time Pin
Eddy Vluggen4-Jun-17 2:55
professionalEddy Vluggen4-Jun-17 2:55 
AnswerRe: Configure Remote Machine's IP in C# Service At Install Time Pin
Gerry Schmitz4-Jun-17 4:45
mveGerry Schmitz4-Jun-17 4:45 
QuestionReport cant be display on report viewer page in c#.net windows form Pin
Member 132383512-Jun-17 22:31
Member 132383512-Jun-17 22:31 
AnswerRe: Report cant be display on report viewer page in c#.net windows form Pin
User 41802543-Jun-17 3:32
User 41802543-Jun-17 3:32 
QuestionHow to solve 2 js script file crash problem Pin
Member 130563031-Jun-17 16:22
Member 130563031-Jun-17 16:22 
AnswerRe: How to solve 2 js script file crash problem PinPopular
Gerry Schmitz1-Jun-17 16:47
mveGerry Schmitz1-Jun-17 16:47 
GeneralRe: How to solve 2 js script file crash problem Pin
OriginalGriff1-Jun-17 20:25
mveOriginalGriff1-Jun-17 20:25 
AnswerRe: How to solve 2 js script file crash problem Pin
Pete O'Hanlon1-Jun-17 21:49
mvePete O'Hanlon1-Jun-17 21:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.