Latest Post

Launch External Url in Browser from Windows Store App

The java script code for achieving this: // Create a Uri object from a URI string var uri = new Windows.Foundation.Uri(“http://test.com”); var options = new Windows.System.LauncherOptions(); // Launch the URI with a warning prompt options.treatAsUntrusted = true; // Launch the URI Windows.System.Launcher.launchUriAsync(uri, options).then( function (success) { if (success) { // URI launched } else { // URI launch failed } });  

Quick Tip

Convert C# Object to JSON and create object from JSON string

Json.Net is the preferred way to go about it because of performance gain it gets compared to JavascriptSerializer. Download and install Newtonsoft.Json using Nuget Now in order to create Json for an object simply use SerializeObject method as following Product product = new Product(); product.Name = “Apple”; product.Expiry = new DateTime(2008, 12, 28); product.Sizes = new string[] { “Small” }; string json = JsonConvert.SerializeObject(product); // { // “Name”: “Apple”, // “Expiry”: “2008-12-28T00:00:00”, // “Sizes”: [ // “Small” // ] // } In order to convert Json to the object use DeserializeObject method as following string json = @”{ ‘Name’: ‘Bad Boys’, ‘ReleaseDate’: ‘1995-4-7T00:00:00’, ‘Genres’: [ ‘Action’, ‘Comedy’ ] }”; Movie m = JsonConvert.DeserializeObject<Movie>(json); string name = m.Name; // Bad Boys  

Commenting Etiquettes While You are on Web !!

Now a days commenting on posts or blogs is not just what people do out of their interests only but also it is really important to be an active commenter on the social media to mark your presence known and maintain overall awareness about the updates. It helps in building links with others, building a community and sharing your views. Comments also reveal the engagement of your content. While sharing your views anywhere be it on a blog or some social networking post, you have to make sure that your comments are expressed in a good way. There are certain things to be taken care of before you comment. Here they are: • Make Valuable Comments: Make sure to never comment without proper knowledge about the subject and reading of the content. Comments should not be done just to make noise but to add on to the information. You can add a story related to a post[…]

Windows 10 App :Host Defined Policy: Inline Script. Resource will be blocked.

I recently ported one of my java script projects to Windows store app and got the error as following CSP14321: Resource violated directive ‘script-src ms-appx: ‘unsafe-eval’ blob:’ in Host Defined Policy: inline script, in ms-appx://13bdc914-5111-4c95-a5e6-82029c5105ec/index.html at line 21 column 12. Resource will be blocked. If you have something like the following, it won’t work <a href=”javascript:void(0)” id=”somelink” onclick=”callMethod();”>Link</a> Since I was using jQuery in the project, I simply used jQuery to bind click event to the element $(“#somelink”).click(function () { callMethod(); }); and Voila, everything works but I had many pages which had this reference and I had to make this change to all pages. After some research I found that there is an alternate way which is much faster to change. By default ms-appx:/// protocol is used in store apps to fetch the content. For web apps specify a specific protocal ms-appx-web which is then used for the app. This can be done[…]

Quick Tip

Tip of the day: Blank href in html A link

When you are using <a> link and want to bind it with onclick event in stead of href location, it can be set to # as following <a href=”#” onclick=”javascript:callMethod();”>Link</a> As you know setting href to “#some_id” is an approach used to link content inside the page so if you are using above approach, it will make the page jump to top which is not an elegant solution. There is an alternate way which is much better as it does not make page jump. <a href=”javascript:void(0)” onclick=”javascrit:callMethod();”>Link</a> Simple and elegant..  

Error: An invalid APK was received. Not a signed jar file.

When I tried to upload APK file to Aptoide store which was built using cordova and signed for the release version, I got this error An invalid APK was received, does not seem to have all files correctly signed. Please verify apk signature and try again. Signature error: Not a signed jar file The same APK was fine when uploaded on Google Play Store. In order to fix this problem I had to create an unsigned release version of the APK using cordova and then sign it using jarsigner utility. In order to create unsigned release version of the APK, following command can be used cordova build android –release Jarsigner utility comes with java sdk and can be found @ your JDK bin folder (for ex, C:\Program Files\Java\jdk1.8.0_131\bin). The command which can be used to sign the APK is as following jarsigner -verbose -tsa http://timestamp.comodoca.com -keystore android.keystore -storepass password mygame.apk alias[…]

How to avoid screen flicker when embedding responsive Phaser game in Bootstrap site

Phaser games can be responsive and will fit in the available space which makes it easy to embed in variety of devices with different sizes. When Phaser games are embeded in a Bootstrap site which is responsive, there can be some flickering on the web page when game is initially loaded. When Phaser games are loaded, it loads in the actual size it was created in and afterwards CANVAS is resized to fit in the available space. The example below is a bootstrap template in which Phaser game is embeded in half of the screen and remaining half screen has some other content. Click the link to load the page to see how the game is being resized to fit in the available space. To make the game load in a nice manner without visible resizing, we need to intially hide the div in which game is loaded. In Phaser boot method we can[…]

Manage Amazon Promotions in ASP.NET Application

If you are into affiliate marketing then you must be getting promo codes from your partners which are promoted on various platforms. For ex, Amazon publishes promo codes for Associates which can then be pormoted by the Associates and they get a cut from the sales. Its a nice way to boost conversion and earn commission. Associates share the link to temporary promotion pages which is tagged with their affiliate id. These promotions run for a short duration and need to be managed more frequently by adding/removing them from your site almost on a daily basis so it makes sense to have a small database at your end which you can use to manage it at your end and it can also take care of the promotions which have ended. If a promotion has ended, Amazon takes you to the deals page when a promotion link is clicked but it makes[…]

URL Rewrite SEO in IIS

Since the advent of search engines URL rewriting has become mandatory. It makes URLs look nicer and clearer in terms of what content to expect at the given URL. Recently I uploaded few static HTML files to an IIS site. I wanted a nice looking URL without .html extension which was quite straight-forward to achieve in ASP.NET site. You can install URL Rewrite Module in IIS 7 or above versions and a few configuration steps is all that is required to achieve the desired results. Read this article from Microsoft to get in-depth understanding of the steps. Below is the sample web.config entry I had to make to achieve the results <configuration> <system.webServer> <rewrite> <rules> <rule name=”Rewrite to .html Rule”> <match url=”^games/([_0-9a-z-]+)” /> <action type=”Rewrite” url=”games/{R:1}.html” /> </rule> </rules> </rewrite> </system.webServer> </configuration> You will need some understanding of the regular expressions to create a matching pattern for your URL (match tag in[…]