Welcome on Kweetix Technical Blog

Monday, October 28, 2013

Windows Setup: Installing using the MBR or GPT partition style

My problem was that I bought a Windows 8 preinstalled laptop and I wanted to reinstall it with Windows 8 Pro. Then I booted in legacy BIOS-compatibility mode but the setup didn't let me install on the partition because it was preinstalled with GPT partition style.

I found an article on Microsoft Technet that helped me (http://technet.microsoft.com/en-us/library/dn336946.aspx) to solve my problem.

When installing Windows on UEFI-based PCs using Windows Setup, your hard drive partition style must be set up to support either UEFI mode or legacy BIOS-compatibility mode.

For example, if you receive the error message: “Windows cannot be installed to this disk. The selected disk is not of the GPT partition style”, it’s because your PC is booted in UEFI mode, but your hard drive is not configured for UEFI mode. 

NB: For me the problem was the inverse (booted in Legacy, install on a GPT partition).

You’ve got a few options:


  • Reboot the PC in legacy BIOS-compatibility mode. This option lets you keep the existing partition style. For more info, see Boot a PC in UEFI Mode or Legacy BIOS-compatibility mode.
  • Reformat the drive for UEFI by using the GPT partition style. This option lets you use the PC’s UEFI firmware features.

Reformatting the drive using a different partition style

From inside Windows Setup, press Shift+F10 to open a command prompt window.
Reformat your drive:
UEFI mode: Use DiskPart to clean the drive and convert it to the GPT partition style:

diskpart
list disk
select disk <disk number>
clean
convert gpt
exit
Legacy BIOS-compatibility mode: Use DiskPart to clean the drive and use the default partition style (MBR):

diskpart
list disk
select disk <disk number>
clean
exit

NB : I used this second solution to reset my disk to MBR, then I rebooted and was able to install Windows.

Because I already deleted the GPT partition before finding this article, I booted in UEFI mode then Windows tried to make a recovery. But it said it couldn't solve the issue and proposed some options to me. Browsing these options, I found a command prompt where I could enter the above commands.

At this point, you can close the command prompt window and then continue the Windows Setup installation.

Thursday, October 3, 2013

Cross-domain jquery ajax call : How to implement CORS for WCF

First, I changed my AJAX calls (GET / POST) from json to jsonp.

$.ajax({ type: 'GET', url: url, dataType: 'json', data: parameters, headers: { "cache-control": "no-cache" }, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

$.ajax({ type: 'POST', url: url, dataType: 'json', contentType: 'application/json', processData: false, data: parameters, headers: { "cache-control": "no-cache" }, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

became :

$.ajax({ type: 'GET', url: url, dataType: 'jsonp', data: parameters, headers: { "cache-control": "no-cache" }, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

$.ajax({ type: 'POST', url: url, dataType: 'jsonp', contentType: 'application/json', processData: false, data: parameters, headers: { "cache-control": "no-cache" }, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

That way worked but I had a problem with the encoding of the data I received. Then I added for GET requests :

scriptCharset: 'utf-8'

It became :

$.ajax({ type: 'GET', url: url, dataType: 'jsonp', scriptCharset: 'utf-8', data: parameters, headers: { "cache-control": "no-cache" }, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

Everything was fine... until I tried a POST request. It worked before but now I received : Method not allowed.

Nothing to do until I tried to implement CORS for my WCF. It was a very simple solution that worked.

Here's how I did :

1. Add a Global.asax to your WCF application.

2. In "Application_BeginRequest", add the following code :

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();

// Enable Crossdomain Ajax calls

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");

if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}

3. Come back with the first version of the Ajax call and remove the headers property :

$.ajax({ type: 'GET', url: url, dataType: 'json', data: parameters, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

$.ajax({ type: 'POST', url: url, dataType: 'json', contentType: 'application/json', processData: false, data: parameters, success: function (response, status, xhr) { successCallback(response, status, xhr); }, error: function (xhr, status, error) { errorCallback(xhr, status, error); } });

That did the trick for me...