Mark Coffman
http://markcoffman.com
Mark Coffman

DNN Setup Underway, metaPost installed, and WLPG tutorial in the works

Nights are different now.  I am hard at work each night updating the site and getting my tutorials posted. 

 

MVPLogo

 

Get ready... your digital memories are going to be protected.

Custom Error Pages Except in a Sub Folder

I tried all the complex ways to do something which turned out to be quite simple. 

I had a need to show nice-looking custom error page in my asp.net application for all folders except one.  That special folder needed to return a proper error code and not a 302 (redirect to a custom error page) status.

While it was simple enough to make the custom error page set a Response.StatusCode = 500, I could tell with my Http Proxy sniffing tool Fiddler that the first code sent was the 302.  This wasn’t good.  I had to be sure that if there was an error, that the requesting client got an error code, not a redirect code, and worse yet, a redirect to a 200 OK code.

The solution was simple:  in my application’s web.config, set a location-specific customErrors directive:

  <location path="specialFolder">
    <system.web>
      <customErrors defaultRedirect="" mode="RemoteOnly"></customErrors>
    </system.web>
  </location>

The important part here is to specify a defaultRedirect="". This solved my issue, and is now good again.

Microsoft Please Fix Upgrade Option on Visual Studio 2008

I installed the 90 day trial of VS2008 at work.  My trial period is almost up, so I figured I'd go ahead and Upgrade to the purchased product.  I was assured when I downloaded the trial that I would simply have to enter the key (not do a reinstall) when my trial was up.

Well, I hit Upgrade.  I am not sure what is wrong with the Microsoft servers, but Upgrade sends me to a Content Not Found page on msdn.mcirosoft.com.

Strike one.

I won't give up that easily.  The product is great even if the sales site needs work.  So I decided to try to buy it another way.  I called support.  They were very helpful, but all of their answers pointed me in directions that got physical media and not a key.  Keep in mind, my trial is running out.  I do have 3 days left, so I didn't wait until the last second, but what if I did?  Would I be forced to stop working until my physical media was shipped to me?

Strike two.

I am searching the site. 

Here is a product page for Visual Studio 2008 Professional Edition.  I see a Trial Download button.  Why not a Buy Now button? 

http://msdn.microsoft.com/en-us/vs2008/products/bb894671.aspx

I clicked Download.  Here I have a paragraph that looks helpful:




Upgrading from Trial Editions

When you are ready to upgrade from an installed trial edition of Visual Studio or Team Foundation Server (or the Workgroup Edition of Team Foundation Server), you don't have to completely uninstall and reinstall those products. For more information, see How to: Upgrade from Visual Studio Trial Edition (a Visual Studio 2005 topic, but still accurate).






Clicking that link gives me another potentially helpful page (although I see it is geared toward 2005, not 2008):  http://msdn.microsoft.com/vstudio/howtobuy/.

Content not found.

Sigh.


Linq Results for Paging in a Datagrid

Today I was using c#'s new Linq technology to query a list of objects.  To keep my test simple, I decided to try ordering my objects.

My code look looked like this:

var query = from o in referrals orderby o.Email select o;

I bound this to a gridview.  Everything looked ok until runtime.  My datagrid complained:

The data source does not support server-side data paging.

 A quick google search revealed a post by Scott Guthrie.  I need to tell Linq that I wanted this list back in a form that the datagrid could page.  Modified:

var query = (from o in referrals orderby o.Email select o).ToList() ;

This worked well, and gave me my referral list back, ordered by the Referral object's Email attribute.  Of course, this only scratches the surface of what Linq can do, as filtering or joining of that list would be better examples of the power of Linq.

Upgrading from VS2005 to VS2008

I upgraded from VS2005 to VS2008 today.  The first server I publised to went off without a hitch.  I'm glad, because that gave me confidence that VS2008 was going to be a fairly easy upgrade.

Prior to upgrading, I did some research and found that .NET 3.5 is really the .NET 2.0 core with some added referenced assemblies.  Because of that, IIS still gives only the two options of ASP.NET 1.1 or 2.0.  Knowing that going in probably saved a lot of time because my next publish to another server revealed this issue:


 

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Child nodes not allowed.

Source Error:

Line 78: <compilers> Line 79: <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> Line 80: <providerOption name="CompilerVersion" value="v3.5"/> Line 81: <providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom> Line 82: <runtime>

Source File: C:\Inetpub\devads.sundropsystems.com\web.config    Line: 80


Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832  
 




Luckily, the solution to this problem was easily found.  It turns out that my 2nd server had 2 updates to .NET waiting in Windows Update.

KB110806 - .NET Framework 2.0 SP1
KB929300 - .NET Framework 3.0 SP1

These patches allow .NET to understand these child nodes: providerOption