Category Archives: Asp.net Errors

Debugging JavaScript in asp.net User Controls

Little while back I was facing issue is debugging JavaScript code written inside an asp.net User Control (ascx) file in visual studio 2010.

Interesting thing is that breakpoints doesn’t work for User Controls in asp.net but you could still do the debugging if you write debugger; keyword before the line where you want to set the breakpoint. The visual studio will automatically detect this keyword in your code and would pause the execution at that line in debug mode.

But in my case even the debugger keyword was not working. Whenever visual studio designer used to encounter this keyword, VS used to halt at the first line of page’s markup (pagename.asps[dynamic]), and by this I could not find that exactly which of my debugger statement got hit.

The issue seems to be of the page’s temporary file/markup generated by VS.

Solution

deleted the website’s .pdb file from project’s bin folder and things started working.

Hope this information would help someone other there in coding world.

Thanks


Parameter is not valid. Asp.net GDI exception

I was getting this exception while working with the GDI images in asp.net.
My requirement was to upload the image from client then resize it and display.

The code was working fine on local development machine, but on production server it was throwing “Parameter is not valid” exception.

The general cause of this is that non-availability of resources required to generate a valid image file.

In my case the reason was that the destination folder was having read-only permissions, which was causing the code to hault while saving the processed image back to server.

For the resources I read during this issue, I found out some more reasons, these can be following:
1) Invalid source image path passed to the Drawing/Image/Bitmap object.
2) Invalid destination image path passed to the Drawing/Image/Bitmap object.
3) Corrupted/incomplete byte array.
4) Disposing of Source object before completing generation of new Image.
5) Folder write permissions while saving the new file.


Unable to validate data, ASP.net error

Error:
Unable to validate data, ASP.net error at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)

Information:
This is an View state decoding error.

Cause:
The basic reason of this is the difference of key while encrypting and decrypting the viewstate data. Suppose an asp.net rendered a page with key1 and saved the page state in view state, meanwhile asp.net’s key is changed to key2, now when some server side event will occur on page the viewstate will get decrypted and this error will occur as the old view state is now not valid due to a different encryption key.

It may occur when you open a page for along time and after that do some events on that.

Solution
Fix the key in your web.config file, so that only one key is used to encrypt and decrypt the viewstate data.

For more information visit:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21321364.html

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312906