Category Archives: Windows Emulators

jQuery AJAX file upload from html5 canvas – not working via AJAX POST

Published by:

If your code is right and you are using something like this:

var imgUrlCanvas= document.getElementById(“canvas”).toDataURL(“image/png”);
imgUrlCanvas = imgUrlCanvas.replace(‘data:image/png;base64,’, ”);

$.ajax({
type: ‘POST’,
url: “fileupload.aspx/UploadCanvasImage”,
data: ‘{ “imageData” : “‘ + dataURL + ‘” }’,
contentType: ‘application/json; charset=utf-8’,
dataType: ‘json’,
success: function (msg) {
alert(msg.d);
}
});

 

and your .ASPX or MVC is like this:

[WebMethod]
public static string UploadCanvasImage(string canvasImgData)
{
string Pic_Path = HttpContext.Current.Server.MapPath(“MyPicture.png”);
using (FileStream fs = new FileStream(Pic_Path, FileMode.Create))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
byte[] data = Convert.FromBase64String(canvasImgData);
bw.Write(data);
bw.Close();
}
}
return “success”;
}

 

You, find out that the the WebMethod method is not being called.

Reason: It seems the canvas image is large.

You need to add this to the web.config to make this work:

<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength=”10000000″ />
</webServices>
</scripting>
</system.web.extensions>

 

Now, the JQUERY AJAX will be able to call the method successfully.

Prevent scrolling and zooming on touch within the browsers in mobile devices

Published by:

If you want that a user should not be able to scroll or zoom via touch in the web browser of a mobile device, use this code in the HTML:

<!–Prevents iPhone, iPad, and touch devices from scrolling or zooming when touched–>
<meta name=”viewport” content=”width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0″ />
Enjoy the tip!

Note: Most useful: when you are building and interactive HTML5 Canvas!

Windows 8.1, Windows 10 Emulators crashing in Visual Studio 2015

Published by:

Problem:

windows-phone-emulator-error

a) I start Visual Studio and create/open Windows Universal Apps. Then I choose the appropriate Windows 8.1/Windows 10 emulator and start the debug.

b) The Emulator loads and shows “OS is starting” and keeps stuck there for long time. Then finally loads a popup giving this error:
“windows phone emulator is unable to connect to the windows phone operating system couldn’t set up the UDP port”

Seems pretty bad, right? Cursing the operating system guys? hmmmm.

Solution (will work no matter what):

a) Do not think about reinstalling stuff or repairing Visual Studio 2015/previous versions or reinstalling Hyper V, etc.

Try this OPTION I  first:

1.) Open Hyper-V

2.) Shutdown any existing configured Windows Phone emulators.

3.) Delete the existing Phone emulators you see in the list

3.) Click on “Virtual Switch Manager”

4.) Click on the “Windows Phone Emulator Internal Switch”

5.) Delete the existing “Windows Phone Emulator Internal Switch” by clicking “Remove”

6.) Click “Apply” and “OK”

This should work.

If this does not, then do this:

OPTION II:

1.) All steps in OPTION 1

2.) Now, open “Network Connections”

3.) You will see there “vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch)”

4.) But hey, you deleted this same switch in OPTION 1, but still it shows in the Network Connections page.

This is the problem.

5.) Now open Device Manager

6.)  Expand “Network Adapters”

7.) You will see the names appearing under Network Adapter match the same as “Device Name” mentioned in “Network Connections” window (option II.2)

8.) Find out the correct “Hyper-V Virtual Ethernet Adapter” to be removed.
(Please note that on your computer the name could be “Hyper-V Virtual Ethernet Adapter #2” or “Hyper-V Virtual Ethernet Adapter #3” or anything that would match the “Device Name” of OPTION II.3)

9.) Now, in Device Manager, right click the correct Network Adapter and choose “Uninstall”.
This should disappear from the list.

10.) Open “Network Connections” and see that “vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch)” will no longer be present there.

11.) Open Visual Studio, run the project in your desired emulator.

12.) This time everything will work fine and the Emulator will boot up Windows 10 or Windows 8.

Enjoy.

Love,
Angel Kaushish
(Microsoft Certified Solutions Developer)