Sandip's Programming Zen

An attempt to share tech/coding experiences

Archive for the ‘Troubleshooting’ Category

“Length Required” in Firefox with AJAX POST

with one comment

I have a code which makes Ajax post using JQuery in asp.net. It worked fine in IE and Chrome but failed in Firefox. When debugged using Firebug it showed 411 “Lenght Required” error. After wasting couple of hours on google it finally turned out a kind of Jquery bug.

Normally I wrote code like:

    $.ajax({ type: “POST”,
        url: “URL”,
        dataType: “xml”,
        processData: true,
        error: function(XMLHttpRequest, textStatus, errorThrown) {},
        success: {}
    });

Looks normal and works in IE and Chrome but not in FF, to make work in FF we have to provide an empty data header like below:

    $.ajax({ type: “POST”,
        url: “URL”,
        dataType: “xml”,
        data:{},
        processData: true,
        error: function(XMLHttpRequest, textStatus, errorThrown) {},
        success: {}
    });

It is weird because there are so many other headers which we don’t pass it too and they are taken with default values and why not with data header.

Hope it will be solved in upcoming jquery releases and till then hope this helps.

Written by Sandip

February 14, 2009 at 12:53 pm

Posted in Troubleshooting

Vertically Align content in div tag

leave a comment »

I needed to align content bottom-up for one web-based IM interface, searched around but could not find a perfect solution after a while, so here is how I solved the problem:

<div style="height:400px;width:100%">

 <table style="border:0;height:400px;width:100%;overflow:scroll">

            <tr>

            <td  id="TableInner" style="vertical-align:bottom;">

            </td>

            </tr>

          </table>

</div>

In above code, key is to put a table inside a div. Vertical-Align does not work on div tag so no matter what style you apply it will never work. by default it will align top. by putting same Size of table inside div we create another container for our content. Now we can apply vertical-align:bottom to TD tag of our table. Whatever content we need to put now we put it inside that TD tag. problem solved.   The outer div around table provides the scrollbars to our content if it overflows.

In addition if you need to set scroll position of Div to bottom then following Javascript will do that:

var objScr = document.getElementById(‘myDiv’); 

objScr.scrollTop = objScr.scrollHeight;

 

Hope this helps.

Written by Sandip

February 13, 2009 at 1:55 am

Posted in Troubleshooting

ASP.NET Webservices: “The request failed with HTTP status 401: Access Denied.” Error

leave a comment »

I have faced this issue today and thought it would be useful to share.

We can solve this issue in following way.

In IIS 7:

1. Right Click on Authentication feature and select Edit Feature.

2. Right Click on Anonymous Authentication and select Edit.

3. Either put IUSR_XXX account in Specific User or Just select Application Pool Identity (whatever works in your case).

IIS7


In IIS 5/6:

1. Click “Start” – “Run” – Type “inetmgr” and press “Ok” or “Enter” Key

2. IIS Control panel opens.

3. Expand the appropriate nodes and navigate to the virtual directory of your Web Service Application.

4. Select the Virtual directory, Right Click and select “Properties”

5. Switch to the “Directory Security” Tab and then Click “Edit”.

6. Check the “Anonymous Access” CheckBox.

7. Click “Ok” twice to exit.

This should solve the issue.

Written by Sandip

November 27, 2008 at 2:10 pm

Posted in .Net, Troubleshooting

Tagged with , ,

Running Asp.Net 1.1 and 2.0 together in Windows 64-bit environment

leave a comment »

To be noted, Microsoft is not going to release 64-bit version of .Net framework 1.1. So installing it on Windows 2003 64-bit OS will require it to run in “32-bit mode”. Normally this is done easily when you try to install FW 1.1 on OS it will ask you to run a command during installation and that enables IIS to run FW 1.1 in 32-bit mode.

Asp.Net Tab in IIS MMC will be missing so assigning different FW version to different websites should be done using command line tool : aspnet_regiis.exe (it is separate for each FW version and can be found in framework directory e.g. C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322)

Examples:
aspnet_regiis.exe -s W3SVC/1/ROOT/<yourappname>       (for recursive update)
aspnet_regiis.exe -sn W3SVC/1/ROOT/<yourappname>     (for non-recursive update)

For more details visit here.

Written by Sandip

June 26, 2008 at 10:45 am

Posted in Troubleshooting

Tagged with , ,

Solution: ERROR 2003, Can’t connect to MySQL server on ‘localhost’ (10048)

with 8 comments

The behavior is seen on Windows Server 2003.

If your application is using data connections in large numbers than sooner or later it will stop responding after some time and only way to make it working again is resetting iis service.

Asp.Net is using Ephemeral Ports to connect MySql via ODBC but in Windows 2003 server there is no maximum port value defined in registry (surprisingly on Windows XP it is). So after consuming certain number of ports there are no ports available to connect and finally application crashes. I have resolved this issue by creating MaxUserPort value in registry in following way. This has solved my problem.

1. Click Start, click Run, type regedit.exe, and then click OK.

2. Locate and then click the following registry subkey:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

3. On the Edit menu, point to New, and then click DWORD Value.

4. Type MaxUserPort and then press ENTER.

5. Double-click the MaxUserPort value, and then type the maximum value in decimal or hexadecimal.

You must type a number in the range of 500065534 (decimal). Setting this parameter to a value outside of the valid range causes the nearest valid value to be used (5000 or 65534).

6. Click OK.

7. Quit Registry Editor.

Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Use this solution on your Own risk.

Written by Sandip

February 19, 2008 at 1:31 pm

Posted in Troubleshooting

Solution: Error, Operation must use an updatable query

with 9 comments

This is a common error I have seen developers encounter many times when they are using MS Access database in their .Net application. It occurs when you try to Add, update or delete any record.

Reason: Your database is in a folder where there is no write/change permission.

Resolution:

If using Windows 2000 – IIS5
– the {Server}\ASPNET User Account must have Read, Write, and Change Control of the Folder where database resides

If using Windows 2003 – IIS6
– the NETWORK SERVICE User Account must have Read, Write, and Change Control of the Folder where database resides

Giving EVERYONE account full control will solve your problem too but Never do that as it will expose your system to external attacks within network.

Written by Sandip

February 13, 2008 at 4:27 pm

Posted in Troubleshooting

Solution: Timeout expired – Connection Pool Error

with 8 comments

“Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached.”

How many times you have got above error? I have got it number of time but I was not troubled much as I did last time.

We have done following to resolve error (in sequence):

  1. Tried to check obvious code if we can find faulty code.
  2. Ran SQL profiler on Live scenario and gather as much data as possible
  3. Checked SQL server log for possible error messages.
  4. Checked Eventviewer for application error messages.
  5. Tried increasing connection pool value in web.config

None of above helped in our case at last we checked sql locks in syslocks table in master database which continuously holding lock on one of our primary tables. Some how lock was created and never removed during a simple update query, normally sql server creates lock on table when any insert/update/delete transaction is in progress.
We commented that update query and locking issue is gone and everything worked perfectly, no time out errors now.

As of now we don’t have any idea why a simple update query which was working normally, suddenly creating a permanent lock on a table, if I will find out with the help of my team will update here.

I suggest if you ever encounter this error try to follow the steps in the sequence I have mentioned above and narrow down the possibilities.

Update: If you want to set timeout property in DTS package than you can use timeout property shown in the screenshot below:

 

Written by Sandip

January 29, 2008 at 7:06 pm

Solution: Event ID ( 0 ) Error – Application Crashing

with one comment

Recently I have got a weird error on our production web server. The server is Win 2003 R2 running with Framework 1.1 application.

The following error is logged in event viewer and whenever it occurred our server crashed and mostly we have to reboot to make the application working.

The description for Event ID ( 0 ) in Source ( .NET Runtime ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: .NET Runtime version 1.1.4322.2300- Setup Error: Failed to load resources from resource file.

As it seems it does not provide any clue what is going wrong. After researching Net for hours I have seen number of people reporting this error in different context. So there is no fixed reason or solution.

However, I have tried to do everything what some people have suggested as solutions and one had done the trick for me. I am putting them together some of the possible solutions (as I believed) those may fix the problem if you ever encounter.

  1. Stake overflow is the number one cause according to most and it usually happens because of recursive function in code. You have to go through your code and find out and fix.
  2. As it gives a hint in message itself “Failed to load resources from resource file“. Means you may be using a resource file in your application and now it can’t be loaded or accessed.
  3. Check in your code if there are any threads which stuck in any of your function and goes into infinite loop. This can be easily found out as this may be happening on carrying out particular action on your application.
  4. If you have used any “third party” library where you don’t know how it works inside then better check. Try to remove them from your project and see if the error goes away.

If you find more solutions then please update me as that may save someone’s hours of time.

Written by Sandip

January 25, 2008 at 5:10 pm