This is a new Silverlight spin on an old problem. Let's say you have a Default.aspx page with some code behind logic in it. One day you notice using the debugger that the code-behind logic in Default.aspx.cs is always executed - even when accessing a different aspx page.
This problem can arise for a couple of common reasons. One reason is that someone copied the Default.aspx page to a new page and forgot to change the Codebehind and Inherits page directives to a new code-behind class. You can usually solve this by searching other pages for references to _Default in their page header:
<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false"
Inherits="VersaTrans.GPS.Web.UI._Default" %>
Another more common reason though, is that you have dynamically assigned a Url for a resource, such as an img src, and the src attribute evaluates to an empty string:
<IMG src='<%# Eval("ImageUrl") %>'>
... if bound to an empty field, would evaluate to:
<IMG src="">
When this happens, the Request will go to the root of your website, which in turn will execute the default page of your site - normally Default.aspx. You can use a tool such as Fiddler or Web Development Helper to help troubleshoot this issue. By capturing the http traffic, you will see a request for the root of your site.
A Silverlight Twist
The problem described above is hard enough to track down in an ASP.NET environment. But to make it even more confusing, a Silverlight application within the ASP.NET website can also cause the problem.
A common way to dynamically assign an image source in Silverlight is shown below. We create an ImageSource based on Uri and the set the SourceProperty of the Image to the Uri:
Uri imageUri = new Uri(imageUrl, UriKind.Absolute);
ImageSource imgSource = new System.Windows.Media.Imaging.BitmapImage(imageUri);
img.SetValue(Image.SourceProperty, imgSource);
... but if the variable imageUrl above is an empty string, we are back to the same issue described above for the ASP.NET environment. The browser will request the root of the web site, and the default page will be executed.
To avoid this problem, check for empty Image Source's when assigning Url's to image objects.