Friday, 6 June 2014

What WCF bindings to use with Windows Phone 8



If like me you are using .NET 4, you are limited in options for bindings you can use with Windows Phone 8 client. There are only 3 default bindings available and out of these NetHttpBinding is only available on .Net 4.5. Hence you are only left with basicHttpBinding and NetTcpBinding. If you are looking for reliable messaging and session support, NetTcpBinding is only one which ticks all the boxes.

To modify your basicHttpBinding to netTCPBinding, change the endpoint address to be net.tcp:// (instead of http://)

Moreover make sure that ".NET Features -> WCF Activation -> Non-HTTP activation" feature is installed ("server manager -> add/remove features"). If you are hosting on IIS, also check if net.tcp protocol is allowed for a web site(Web Site -> Advanced Settings -> Enabled Protocols) and "Net.Tcp Listener Adapter" windows service is running.

Thursday, 29 May 2014

Using jquery dialog autoOpen instead of open

While working on a dropdown control, I realised that the first time I change the selection in the dropdown, it was calling $(document).ready function.

This was happening because on changing the selection, I was opening a jquery dialog. This dialog had the following structure

$('#name).dialog({
title: 'abc',
height: 200,
width: 600,
modal: true,
open: function (event, ui) {
$(this).css('font-style', 'normal').html(alertmsg);
}

Now open in the dialog was triggering the document.ready. I change removed that, and added autoOpen: true.

This fixed the problem!






           

           
 
 



           

               




},

Friday, 23 May 2014

PostbackUrl vs NavigateUrl

While creating menu items, I was reminded of the difference between the HyperLink.NavigateUrl and LinkButton.PostbackUrl.

HyperLink.NavigateUrl  submits a GET request, whereas PostbackUrl submits a post. Since I wanted the menu item to navigate user to a page created from ASP MVC action method, I needed a GET request; hence HyperLink.NavigateUrl !

Tuesday, 20 May 2014

Develop Windows Phone 8 app on Windows 7 OS

Till recently, in order to build Windows Phone 8 apps, user needed Windows 8 OS. Not any longer!!

Now with Visual Studio 2013 Update 2, you can build WP8 apps on Windows 7. So no need to upgrade your computer.

You will still not be able to debug using emulator, as Emulator requires Hyper-V which can only be found on Windows 8. However if you have an unlocked Windows 8 phone, there is no need for emulator. Just connect your phone to PC. Visual Studio will only show "Device" option for debugging. Select Debug and the debug version of your app will be deployed to your phone.

Feel free to ask me if you have any questions!.

Otherwise happy apping! :)

Thursday, 26 September 2013

scrollHeight problems with IE8


scrollHeight property does not work on IE8 and older IE browsers.

The workaround is to call the property before using it.

var tbox = document.querySelectorAll('[id^="transtext"]');

            for (var i = 0; i < tbox.length; i++) {

                tbox[i].style.height = 'auto';

                //put this line to make it work

                tbox[i].scrollHeight;

                tbox[i].style.height = tbox[i].scrollHeight + 'px';

            }

Useful link:

Tuesday, 30 July 2013

Site on a stick


Today I explored the idea of getting Apache webserver on a memory stick using XAMPP software.


 
The problem with this approach is that an ASP website will need to be ported to run on apache.

To accomplish this we will have to use additional tools like:

http://sourceforge.net/projects/mod-aspdotnet - this looked outdated and probably is no longer supported

http://www.mono-project.com/ASP.NET - this should work, but not sure of commercial licencing.
 

To avoid this, its better to use IIS Express 7.5.


 

The other problem is how to install SQL server on the memory stick. It is possible to install the data file on the memory stick, but the software will still need to installed on the native machine.

It is possible to migrate SQL server to another database like SQL Server CE or MySQL and then port it to memory stick.
 

SQL CE does not support Stored procedures. So using SQL CE will imply rewriting all SPs in code using LINQ.
 

The other option is to install Windows 8 operating system on the memory stick.

http://www.microsoft.com/en-us/windows/enterprise/products-and-technologies/devices/windowstogo.aspx


You can then install IIS express and SQL Server express on the portable operating system.

Monday, 15 July 2013

Improving performance by using Snapshot isolation level


While working on the performance tuning on the my website, I was getting the following error:

Transaction (Process ID XXX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

To reduce this deadlock, I changed the default isolation level of the database to Snapshot.

ALTER DATABASE dBname

SET ALLOW_SNAPSHOT_ISOLATION ON

ALTER DATABASE dBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

ALTER DATABASE dBname SET READ_COMMITTED_SNAPSHOT ON;

ALTER DATABASE dBname SET MULTI_USER;
 
I then changed the webservice calls to the database, such that the transaction scope for all read operations is set to IsolationLevel.Snapshot
 
var _transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Snapshot, Timeout = TimeSpan.FromMinutes(1) });

More information on snapshot isolation level can be found here:


It implements optimistic concurrency – such that user can read the last committed data, while its being modified.