Showing posts with label ASP.NET. Show all posts
Showing posts with label ASP.NET. Show all posts

Jul 14, 2011

Application suddenly becomes slow

I experienced this while I was developing my application in Visual Studio.
It happened for no apparent reason (I didn't remember to make any signifficant changes in this application).

It was really frustrating. The thought that I may need to rething the whole application was a nightmare.

I was in panic and started to think what the problem for this sudden degradation might be.

And guess what?
It appeared to be because of a conditional breakpoint I have set in one of the complex modules.

The program flow was passing through this line of code hundreds of thousand of times so Visual Studio was kind of slow determining if the condition for the breakpoint is true or not.

So remember this for the rest of your life:
"Conditional breakpoints may slow your application considerably, before doing stupid things in case of sudden performance degradation - be sure to remove your breakpoints first (Debug Menu => Disable All Break Points), then check the performance again.".

Jun 28, 2011

WebForm_InitCallback is not defined error (and some resolutions)

I was happilly working while all the sudden I started to get this message.
It took some googlin' in order to understand what is going on.

It was because my development server date was wrong (few months in the past).
Synchronizing it resolved the issue.
Also I read you may experience this problem in case you are changing the current thread culture.

Hope this helps ...

May 6, 2011

Having column display name in RadGrid Column chooser but not in the header of the grid

A little bit of background for this one.

I had a Telerik RadGrid that was having few columns ...

It had the column chooser enabled. Few of the columns were icons (for example “Answered”, “Rating”).

I wanted to have them without header text so I added the Template column and everything was just fine.

Until I right clicked on the header in order to show the column chooser. It was displaying the columns with auto generated names like “GridTemplateColumn7”, “GridTemplateColumn10”.

My goal was to keep the header of the grid clean (e.g. no label) because the icons were 16x16 and that’s all the space I needed to occupy with those columns, having a header “Answered” would extend the entire column. So to solve this case here is what I did:

Solution:

1. Added header text to the column and saw that the header text is appearing in the column chooser.

2. To hide it from the header of the column I added an empty <HeaderTemplae>.

The column should look like this:

<telerik:GridTemplateColumn HeaderText="Bookmark">
    <HeaderTemplate>
    </HeaderTemplate>
    <ItemTemplate>
    </ItemTemplate>
</telerik:GridTemplateColumn>

 

This would solve the problem for Template columns (and all column types that allow you to define HeaderTemplate). This will not work for GridBoundColumn for example as this type doesn’t have HeaderTemplate.

 

Hope this helps someone out there …

Apr 17, 2011

Unable to start debugging on the server.

Lot's of such errors, lots of resolutions.
I had another one, the full message is:

Unable to start debugging on the server. An authentication error occured while communicating with the web server. Please see Help for assistance.

It looks like it is an issue with permissions but the problem is that I disabled the "HTTP Keep-Alive" signals for the web site.

Hope this saves few minutes of research ;).

Feb 2, 2011

Copy XmlNode from one XmlDocument to another

This one is more for the archive, but it is not widelly used so you may not know it.

In case you need to copy XmlNode from one XmlDocument to another, you need to do two things.

1. Import the XmlNode from the source XmlDocument to the target XmlDocument, using Import(XmlNode node, bool deep) method of the target node,
2. Get the result from this method (it is XmlNode) and use AppendChild method of the node that should be parent of the node to be transfered.

In other words:
XmlDocument sourceDocument = new XmlDocument();
XmlDocument targetDocument = new XmlDocument();

sourceDocument.LoadXml("");
targetDocument.LoadXml("");

XmlNode nodeToImport = sourceDocument.SelectSingleNode("//nodes/sourceNode");
XmlNode importedNode = targetDocument.ImportNode(nodeToImport, true);
XmlNode parentTargetNode = targetDocument.SelectSingleNode("/nodes/targetParentNode");
parentTargetNode.AppendChild(importedNode);

is enough to import the sourceNode with all its child nodes under the targetParentNode of the target document.

Nov 5, 2010

The status code returned from the server was: 12031

If you checked anything on your mind about this code, it may be because of StackOverflow exception rised within your code / or in .NET which is less possible.


Just to let you know as it happened to me ;).

Jul 19, 2010

Site is recycled + ThreadPool.QueueUserWorkItem


Just to let you know that you may experience this issue.

If you have an unhandled exception it may be because of a job queued using ThreadPool.QueueUserWorkItem method.

Actually it appears that although the exception is not affecting the main thread (it was in another one) - the .NET will kill the running process (w3wp in our case).

As far as I read this behavior is implemented since .NET Framework 2.0.
It is because you may miss unhandled exceptions in a child thread (if it's in the main thread the process will be terminated in a windows application).

I imagine each request to a web server as a separate thread so I am kind of worried why unhandled exceptions aren't killing the W3WP process as well.
It only seems to be killed if you create another thread in the request thread and this another child thread exits with unhandled exception.

Will need to investigate a bit more about that.

Jul 14, 2010

Thread was being aborted. Exception on Response.Redirect()

This is actually an old issue but I try to make sure I have most of the things that stopped me at some point so I can easilly search.

So if you experience the "Thread was being aborted." exception on Response.Redirect(string Url), it is because this method internally calls Response.End().

In order to prevent it to do so, you will need to use the overloaded version that requires another boolean parameter (something like "bool endResponse", don't remember it exactly).

So the thing that should solve it is:

Response.Redirect("http://donchevp.blogspot.com", false);
This way you should avoid "Thread was being aborted.".

Hope I helped a bit ...