Plugging holes in the universe, what are you doing today? RSS 2.0
 Wednesday, July 26, 2006

Scheduled for Q3 this year - http://msdn.microsoft.com/vstudio/support/servicing/sp1_vs05/default.aspx

Looking forward to seeing what they've fixed/tweaked as I've got a short list (in my head and should probably write down) of wierdness they'll hopefully have ironed out. But overall it's a nice tool. Makes VS03 feel yesteryear already.

Wednesday, July 26, 2006 11:25:57 PM UTC  #    -
.NET
 Thursday, June 01, 2006

Yesterday I was working on a product list using the Gridview component and needed to render the list of products ordered by category. The list also had to have a subheading for the category of the product e.g.

It took a while to figure out but this article by Tim Heuer (there's a show/hide code at the bottom of the page) helped solve the problem. With a minor modification I got what I wanted.

I didn't require the sorting mechanism so I assigned the DataKeyNames property of the Gridview the names of the fields used to order the list before binding to the datasource so that I could pick out the category ID (line 71) in the controls overridden Render method:

    1         protected override void  Render(HtmlTextWriter writer)

    2         {

    3             Table table = (Table)this.productsGrid.Controls[0];

    4 

    5             int lastCategory = -1;

    6 

    7             foreach(GridViewRow row in productsGrid.Rows)

    8             {

    9                 int realIndex = table.Rows.GetRowIndex(row);

   10                 int currentCategory = Convert.ToInt32(this.productsGrid.DataKeys[row.RowIndex].Values[1]);

   11                 if(currentCategory != lastCategory)

   12                 {

   13                     GridViewRow groupHeaderRow =

   14                         new GridViewRow(realIndex, realIndex, DataControlRowType.Separator, DataControlRowState.Normal);

   15                     TableCell newCell = new TableCell();

   16                     newCell.ColumnSpan = this.productsGrid.Columns.Count;

   17                     newCell.BackColor = System.Drawing.Color.FromArgb(233, 229, 229);

   18                     newCell.ForeColor = System.Drawing.Color.DarkGray;

   19                     newCell.Font.Bold = true;

   20 

   21                     switch(currentCategory)

   22                     {

   23                         case 515:

   24                         case 517:

   25                             newCell.Text = "Home Products";

   26                             break;

   27 

   28                         default:

   29                             newCell.Text = "Business Products";

   30                             break;

   31                     }

   32 

   33                     groupHeaderRow.Cells.Add(newCell);

   34 

   35                     table.Controls.AddAt(realIndex, groupHeaderRow);

   36                     lastCategory = currentCategory;

   37                 }

   38             }

   39 

   40             base.Render(writer);

   41         }

 

Thursday, June 01, 2006 5:23:29 PM UTC  #    -
.NET
 Thursday, May 25, 2006

Yay! MS have a shiney new website just for IIS at http://www.iis.net. If I were you, my first port of call would be the .NET show interview with Bill Staples and Scot Guthrie where they show off some of the really cool features that are going to be part of IIS7.

Thursday, May 25, 2006 11:04:38 PM UTC  #    -
.NET | Techy
 Friday, April 14, 2006

Tess Ferrandez has a great article on why debug=true is generally a bad thing to leave lying around in your ASP.NET app's web.config file. This can be a pain for hosting companies like the one I work for when customers upload their app still as a debug build and with debug=true left switched on. We have shared servers that have up to 700 websites on them and it took us a fair bit of time and effort to tune the Application Pools to work around this problem in ASP.NET 1.x. Fortunately now we get to turn it off globally in the machine.config file in ASP.NET 2.0.

Friday, April 14, 2006 12:41:38 AM UTC  #    -
.NET
 Thursday, April 13, 2006

Doug Stewart has a nice article about keeping your production ASP.NET apps happy and healthy. All good stuff.

Thursday, April 13, 2006 10:01:23 AM UTC  #    -
.NET
 Tuesday, April 04, 2006

This is a pretty handy feature for taking your ASP.NET 2.0 app offline (for maintenance or whatever) and displaying a friendly message explaining why the site is down.

Just place a file called 'App_offline.htm' in the root of your site with whatever message you want to give your users and bingo your app shuts down and the contents of App_offline.htm are served. Just delete or rename App_offline.htm to something else to bring the app back online again.

 

Tuesday, April 04, 2006 12:31:19 AM UTC  #    -
.NET
 Monday, March 13, 2006

You may know this already but if you're running ASP.NET 1.1 and ASP.NET 2.0 on the same box then make sure you create a separate application pool for ASP.NET 2.0. You can just clone the Default Application pool if you want, but that can have security implications if you're box is a shared hosting environment because re-using NETWORK SERVICE as the process identity will leave your 2.0 sites open to file harvesting by Full Trust 1.1 apps (that said you are encrypting your connection strings, aren't you? :-) ).

Once you've created the app domain, goto the site or vdir that needs to run ASP.NET 2.0, open the property pages, choose ASP.NET 2.0 from the ASP.NET tab then choose the new ASP.NET 2.0 Application Pool in Home Directory Tab -> Application Settings: Application Pool drop down.

Failure to run ASP.NET 2.0 in it's own app pool will result in the evil 'Server Application Unavailable' message because the ASP.NET 1.1 and 2.0 runtimes can't co-reside in the same worker process.

Monday, March 13, 2006 12:55:59 AM UTC  #    -
.NET
 Sunday, March 12, 2006

This is old hat and more of a bookmark for me when I bump into this each time I'm working with XML documents that have default namespace declared. But I thought I'd share anyway.

Take the following simple XML document:

<?xml version="1.0" encoding="utf-8" ?>
<
products xmlns="urn:backoffice:products"
>
   <
product id="100-1100"
>
      <
description>JVC CD Player</description
>
      <
price>120.99</price
>
      <
category>100</category
>
   </
product
>
   <
product id="100-1101"
>
      <
description>Sony CD Player</description
>
      <
price>122.99</price
>
      <
category>100</category
>
   </
product
>
   <
product id="100-1102"
>
      <
description>LG DVD Player</description
>
      <
price>109.99</price
>
      <
category>110</category
>
   </
product
>
   <
product id="100-1103"
>
      <
description>Technics DVD Player</description
>
      <
price>199.99</price
>
      <
category>110</category
>
   </
product
>
</
products>

You might expect that the code to select all the product nodes would look like:

XmlNamespaceManager nsm = new XmlNamespaceManager(new NameTable());
nsm.AddNamespace("", "urn:backoffice:products");
XmlNodeList productList = products.SelectNodes("/products/*", nsm);

The above seems the logical thing to do because the default namespace doesn't have a prefix so you naturally go ahead and specify String.Empty (or "", whichever) when adding it to the namespace manager. Additionally if you execute the code and breakpoint after setting adding the namespace and inspect the DefaultNamespace property of 'nsm' you'll see that it's even set to "urn:backoffice:products". However, the XmlNodeList returned from products.SelectNodes has no nodes.

This confused the hell out of me when I first encountered it way back when and I tripped up on it again last week. What's going on?

Basically XPath expressions select nodes that are either in a namespace or in the empty namespace. The XPath expression '/products/*' is selecting nodes from the empty namespace (xmlns="") but the document above is defining a default namespace of 'urn:backoffice:products' which is not the empty namespace. We have to tell XPath to select nodes from the namespace 'urn:backoffice:products' otherwise no nodes will be returned.

So how do we do this?

XmlNamespaceManager nsm = new XmlNamespaceManager(new NameTable());
nsm.AddNamespace(
"p", "urn:backoffice:products");
XmlNodeList productList = products.SelectNodes("/p:products/*", nsm);

We add the namespace with an arbitrary prefix and the XmlNamespaceManager is used to expand 'p' to the default namespace name which then brings the nodes we're interested in into scope.

One thing still puzzles me though is the purpose of the DefaultNamespace property in the XmlNamespaceManager and I guess some digging around will uncover it's intentions because the MS docs are pretty vague.

 

Sunday, March 12, 2006 4:49:49 AM UTC  #    -
.NET
 Thursday, February 23, 2006

This week I'm down at DevWeek 2006 which I also attended last year. It's quite good value for money and the quality of the speakers and topics is good again this year. The sessions I've attended so far are:

Tuesday:

Keynote - Dave Wheeler
Power ASP.NET 2.0 Programming - Jeff Prosise
Exploring Unit Testing with Visual Studio Team System - Kevin Jones
Writing Extensible Applications Using Reflection - Jason Clark

Wednesday:

Understanding Threads and Thread Synchronisation - Jason Clark
Distributed .NET - Ted Neward
Extending System.Xml - Ted Neward
ASP.NET, AJAX, and you: Introducing MS AJAX - Jeff Prosise

It's nice to know from sessions such as the Jason Clark ones that I'm doing all the right things :-)

More later.

Thursday, February 23, 2006 12:48:51 AM UTC  #    -
.NET
 Monday, February 13, 2006

Scott Guthrie announced the release of the second preview of the Web Application Project type for VS05. You can read about it here and download it from here.

Monday, February 13, 2006 10:11:00 PM UTC  #    -
.NET
 Saturday, February 11, 2006

If you're developing Visual Studio 2005 ASP.NET 2.0 websites on Windows 2003 server and you're creating a separate IIS website for each project then there's a new gotcha I discovered today.

I prefer developing on Windows 2003 because at the very least you can organise your web projects more sensibly (and sanely) rather than lumping everything into the Default website. There are also many projects we undertake where we need the whole of an existing site on the dev box when we're adding new functionality - often we find absolute urls to scripts or images and unless the darned code gets to live in its own website it can be a bugger to work with.

I know there's a hack to coerce IIS on XP to have more than one Website but it's inconvenient especially when you need to switch between projects quickly (a current project is having a bunch of new functionality added to two sites which will be shared) and lets face it, it's a dirty hack.

Anyway if you start debugging a VS05 website created under IIS (you really shouldn't use the cassini based thing for anything other than knocking up quicky snippets of code, see: Cassini considered harmful (leastprivilege.com) and you encounter the error: "Unable to start debugging on the web server. Logon failure: unknown user name or bad password" then check out this kb article -

You receive error 401.1 when you browse a Web site that uses Integrated Authentication and is hosted on IIS 5.1 or IIS 6.

You also need to start the Visual Studio Remote Debugging Monitor and make sure your logon is added to the Permissions for Remote Debugging under Tools->Permissions. This seems to be a new thing because VS02/03 worked just fine without it in the past. Now please can I have the last 4 hours of my life back?

Update:

I forgot to add that the following event is logged when the vs 2005 login failure occurs -

Event Type: Failure Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 537
Date:  10/02/2006
Time:  01:40:21
User:  NT AUTHORITY\SYSTEM
Computer: UKM-W2K3-003
Description:
Logon Failure:
  Reason:  An error occurred during logon
  User Name: Kevin
  Domain:  MYSERVER
  Logon Type: 3
  Logon Process: O­
  Authentication Package: NTLM
  Workstation Name: MYSERVER  
  Status code: 0xC000006D
  Substatus code: 0x0
  Caller User Name: -
  Caller Domain: -
  Caller Logon ID: -
  Caller Process ID: -
  Transited Services: -
  Source Network Address: 192.168.100.59
  Source Port: 0



Saturday, February 11, 2006 3:09:01 AM UTC  #    -
.NET
 Tuesday, January 10, 2006

Oldish news now but it's the first chance I've had to play with it.

If you miss the VS.NET 2002/3 web project concept or are migrating larger legacy projects to VS 2005 then this should make your day.

The ASP.NET team have released a preview of the Web Application Project for VS 2005.

One of the neat things is that unlike in VS.NET 2003/3 the dependancy on FPSE to open/edit projects is gone, and gone is the fragile .webinfo file and hardcoded http:// paths in the solution file.

Remember it's a preview and so isn't feature complete yet.

Check out Scott Guthries blog entries:

http://weblogs.asp.net/scottgu/archive/2005/12/07/432630.aspx

http://weblogs.asp.net/scottgu/archive/2005/12/16/433374.aspx

Web Application Project website:

http://webproject.scottgu.com/Default.aspx

Tuesday, January 10, 2006 2:00:34 AM UTC  #    -
.NET
Now Playing
Top Artists This Week
Fluff

Powered by FeedBurner
Categories
Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Kevin Kenny
Sign In
Statistics
Total Posts: 207
This Year: 3
This Month: 0
This Week: 0
Comments: 140
All Content © 2010, Kevin Kenny
DasBlog theme 'Business' created by Christoph De Baene (delarou)