Friday, January 27, 2012

Ajax call fails because of response size

I found that some times my Ajax call was returning failure. Checked the server side, which was found okay. This was because of the size of the response. The default value of JSON response is 102400. I changed it to higher value and it solved the problem. Added following to web.config:

Thursday, March 18, 2010

URL Shortening

URL shortening is a technique on the World Wide Web where a provider converts a long URL into a shorter one. It generates a 3 to 6 character long key for the URL and records it against the original URL in its database. When the user requests the shortened URL (service provider's URL + key) over the web, it retrieves the corresponding actual URL and redirects the user to the actual URL. The first notable URL shortening service, TinyURL, was launched in 2002; however, the idea dates to at least 2001.


Purpose:
  • Copying a URL that is hundreds of characters long can make the URL garbled. A short URL is more useful to copy from an e-mail message or forum post.

  • On Twitter and some instant messaging services, there is a total character limit to messages. Using a URL shortener can enable users to include a URL that would not fit.


URL Shortening Wiki
URL Shortening: Hashes In Practice
Tiny UID Algorithm generation
Creating a short URL service using PHP and MySQL

Saturday, April 25, 2009

MSMQ in work group environment

Recently I realized that my application that was working fine on domain machine wont work on work group environment. On analyzing I found that it was because of the MSMQ that was being used by WCF to communicate. I have used Public queues which are not allowed in work group. I just changed my code to create private queue and it started working fine. I was surprised to know that the trick of making a queue public/private was in its name.
Name = machineName\QueueName - Public Queue
Name = machineName\Private$\QueueName - Public Queue

Unlike Public queue, Private queues can not be created on the remote machine.

I thought all was done and my application will start running fine with this change. However, one more hurdle was waiting its turn. The ServiceHost instantiation reported error
There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information.
The Inner exception read:
An error occurred while opening the queue:The queue does not exist or you do not have sufficient permissions to perform the operation. (-1072824317, 0xc00e0003). The message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that the queue is available to open with the required access mode and authorization.

Prima-facie it looked like a permission/rights issue. I googled the error message and was suggested to try various options like creating the user with same id and password on both the machine and giving full control of the queue to the anonymous user. However, non of them worked.

Finally a trail worked. I just changed URI end point from

net.msmq://machineName/QueueName

to

net.msmq://machineName/private/QueueName

Tuesday, April 21, 2009

Some very good articles related to MSMQ

Unable to create Public/Private queues on remote machine

1) Following is used to create a public queue programmatically
System.Messaging.MessageQueue.Create(@"myMachine\MyQueue");
You can use an overload of the Create method to indicate that you want to create a transactional queue. You can also use a period ( . ) in the path to indicate the local machine.

However, when I tried to create the public queue on the remote machine I got the following exception:

An unhandled exception of type 'System.Messaging.MessageQueueException' occurred in System.Messaging.dll
Additional information: External component has thrown an exception.

I fixed this by assigning 'create queue' rights for the user (through which my application was creating the queue) on 'Messaging Queue' of the target machine.

2) Following is used to create a private queue programmatically System.Messaging.MessageQueue.Create(@"myMachine\Private$\MyQueue");

Private queues can just not be created on remote machine.

Thursday, April 16, 2009

.NET Framework 2.0 SP2 related issue

I installed .NET Framework 2.0 SP2 on my machine and found that my C# ASP.NET application that was running fine started reporting 'Page not found' error. When I clicked 'Submit' button on the login page the application would redirect to 404. To make sure the problem originated because of the SP2, I removed it and found that my application was back to normal. On research I found that Microsoft has released updates to .NET Framework 2.0 SP2. However, that too didnt solved my problem. Ultimately I found that the issue was in the form tag of the login page. The action property was set as “ ”. This was resulting in a page not found error when the page was posted back. .NET Framework 2.0 SP2 didnt liked action=" ". However it is ok if you write action="" or action="#" or action="login.aspx" or remove the action property.