DevCare Slides - Designing Application Authorization

Monday, December 29, 2003 11:19:08 PM (Central Standard Time, UTC-06:00)

Download DesigningApplicationAuthorization.zip below.

DesigningApplicationAuthorization.zip (445.75 KB)

404 for any .aspx after installing IIS

Monday, December 22, 2003 11:41:55 PM (Central Standard Time, UTC-06:00)

After setting up  IIS6 on my Windows 2003 Server I tried to run an ASP.NET application.  I was getting a 404 even though the aspx file existed.  If I hit any non ASP.NET extension (txt, xml, html, htm, asp) it worked fine.  I remapped the aspx files (Knowledge Base Article) with no luck.  After removing IIS and then reinstalling, making sure that I included ASP.NET in the IIS install it worked.

Asynchronous Request Performance using Delegates

Saturday, December 20, 2003 8:17:54 PM (Central Standard Time, UTC-06:00)
One of the reasons this blog is named Discovering .NET, is it seems like that's what I spend a great deal of time doing.  There is not a day that goes by that I don't learn something new about the framework.
 
Today was another one of those days. 
 
I had spent a good part of the day yesterday going through the Async Application Block.  It's really a robust block.  Durable storage of requests that run over a period of time, ability to batch requests and get status on each one in the batch.  Looked like a pretty decent feature set.  It did take some time to get setup, as the actual install instructions were buried in the directory structure.
 
Even though the block would more then meet our needs, it was decided that writing our own implementation to reduce the amount of code surface we would have to maintain would be a better decision.  We were basically looking for a straight forward implementation of a Async batch request.  The Application Block was that and more.  It supported request durability through tables in SQL Server, and required to the installation of two windows services.  One was responsible for requests, while the other was responsible for "garbage collection".  In addition, the data access and exceptions management blocks were leveraged in the implementation.  In all, there was a number of projects involved in the solution.
 
So I forged ahead and implemented a class that would support batch async operations using delegates.  By implementing the batch requests asynchronously, we were hoping to reduce the four requests, each taking 10 seconds (40 seconds for a complete request) to how ever long the longest request took in the batch.
 
What was different about this implementation, it wasn't a "Fire and Forget", nor could I take advantage of a wait handle, as I didn't know which request would take the longest in the batch.
 
I ended up implementing my own blocking code.  The initial cut looked something like this.
 
while(_IsComplete == false) {}
 
It monitored the _IsComplete flag until all requests were complete and the flag was set to true.  Even though the code processed all four requests in about 20 seconds, I expected it to be slightly higher or similar to how long it took to execute just 1 request.  Obviously the first place to look would be at the tight loop I was using to block the thread (the 95% utilization on the CPU might have also given it away).  I tried looking for something similar to what is available in WinForms Application.DoEvents().  I tried the System.Threading.Thread.Sleep(1000), indicating that I wanted to wait for 1 second.  I was able to reduce the total request time to about 14.5 seconds.  I was getting closer.  I noticed that as I reduced the Sleep time, I also reduced the total execution time.  After playing with a couple of scenarios I was able to determine the optimal code:
 
while(_IsComplete == false)
{
     System.Threading.Thread.Sleep(1);
}
 
That's correct, 1 millisecond produced the optimal results, with a final time to process all results at about 9.5 seconds.
 
Yet another discovery today…
 
 

Copying and Compilation Errors during Solution Builds

Saturday, December 20, 2003 7:50:18 PM (Central Standard Time, UTC-06:00)
The IDE can be irritating at times.  Do you ever get this compilation error…

Compiler Error Message: CS0006: Metadata file 'c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\xxxx\934254a0\5606a5c7\assembly\dl2\56405119\009facbd_39b0c301\xxxx.dll' could not be found

To fix this restart IIS.
 
If you get…
 
"Could Not Copy Temporary Files to the Output Directory" which seems to be a pretty popular message when working with multiple projects check out this KB article:
 
 
What has worked for me is to close the solution and compile the solution file with out opening the the VS.NET IDE…  Here is the contents of the .reg file that I use to compile using the context menu in Explorer (notice the framework paths are hard coded, you may need to modify).
 
[HKEY_CLASSES_ROOT\VisualStudio.Solution.7.1\Shell\Build Solution Debug]
 
[HKEY_CLASSES_ROOT\VisualStudio.Solution.7.1\Shell\Build Solution Debug\Command]

@="C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv /rebuild debug \"%1\" /out .\build.txt"


 Note that it will create a build.txt file in the same directory to allow you to view compilation errors, which of course, I am sure there will not be any :-\.

Blog is back up - quicker then expected

Thursday, December 11, 2003 7:38:57 PM (Central Standard Time, UTC-06:00)

The blog was down for most of the afternoon as I was switching to a new provider.  I thought I might run into some issues during the transfer, but everything went smoothly.  Over the next couple weeks I will be experiencing occational outages as I upgrade some software, and upgrade a couple of servers from W2k and NT4 (yes... I said NT4).

Updated to DasBlog 1.5

Tuesday, December 09, 2003 7:52:22 PM (Central Standard Time, UTC-06:00)
I was reading a couple of blogs today and found that DasBlog released 1.5.  I upgraded tonight.  They reorganized the configuration a bit and added a search capability to the blog. This blogging engine is getting more powerful on each release.  The best thing about it is that you also get the source if you want to customize it.  I also just found out that they have a workspace up on GotDotNet.  You can find it here.  If you reading this my API that I added to handle InfoPath RSS posts is working.

Blog going off line…

Monday, December 08, 2003 8:21:51 PM (Central Standard Time, UTC-06:00)
My blog is going off line mid week and will be back up Monday.  I am switching providers.

DevCare Presentation - Designing Application Managed Authorization

Monday, December 08, 2003 10:29:28 AM (Central Standard Time, UTC-06:00)
I am doing a talk on how to role your own authorization framework. There is actually a paper out on MSDN that addresses this same topic.  However, the paper relies entirely on the .NET Framework.  The are a number of possibilities and options and this talk will have additional content focused on those decision points.  The abstract is below.
 
Designing Application Managed Authorization
There are several mechanisms for performing authorization available on the Windows platform.   It’s important you understand what your options are.  This session will walk through those options and then address how to design a reusable authorization application framework when those options don't meet application requirements.  It will focus on common authorization tasks and scenarios, and provide you with guidelines on how to maximize security and performance.  In addition it will demonstrate different approaches and techniques for application managed authorization.
 
The presentation is at the Microsoft office in Bloomington, you can get more information here.

The case of the double post back

Saturday, December 06, 2003 12:57:14 PM (Central Standard Time, UTC-06:00)
Let's just say you were cranking out HTML one day and instead of using the bgcolor attribute on a table to indicate the background color, you used background (which allows you to use an image for the background).
 
Would you think that it would create a double post back when you clicked submit on your form?
 
Well it does… this was a tough one to find in a large application we were working on.  It had been around since at least April of this year (at least that's when it was brought to my attention).   Months later when we were looking into performance and cleanup, we were able to find the source of the problem.
 
It was the background attribute on table that had a hex value for the color white (#FFFFFF).  Here is the offending html here (it's highlighted in yellow):
 
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="DoublePostBack.WebForm1" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

 <HEAD>

  <title>WebForm1</title>

  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">

  <meta name="CODE_LANGUAGE" Content="C#">

  <meta name="vs_defaultClientScript" content="JavaScript">

  <meta name="vs_targetSchema" content="
http://schemas.microsoft.com/intellisense/ie5">

 </HEAD>

 <body MS_POSITIONING="GridLayout">

  <form id="Form2" method="post" runat="server">

   <INPUT type="submit" value="Submit">

   <br/><br/><br/>

   <table background="#FFFFFF" runat="server" ID="Table1">

    <tr>

     <td>This is a table cell.</td>

    </tr>

   </table>

  </form>

 </body>

</HTML>
 
If you remove the background attribute from the code, the double post back is resolved, or you can also put a valid value (like an URL) into the attribute and it will work fine.
 
 


 

Gateway Connected DVD - here and gone

Saturday, December 06, 2003 12:55:19 PM (Central Standard Time, UTC-06:00)
Well, I bought a Christmas present for myself. Connected DVD Player from Gateway.  Finally, I thought I would be able to play some of the those mpg's I have laying around from the PVR I bought for my computer over a year ago.  It's OK watching them on the computer occasionally, but it had gotten to the point that I wouldn't even watch them, because it was more comfortable to sit on the couch and watch a movie in the comfort of my living room.
 
Couple things about the DVD Player you should know before I go into this… I had extremely high expectations for a 1.0 release.  With that said, I had read a number of reviews that gave it pretty solid backing as a must have component. 
 
However, the MPG support didn't work for the MPG files I had PVR'd… needless to say it went back to the local Gateway Country store.  That was the whole reason for buying it in the first place.  Looks like I am going to have to roll my own (looks like the Shuttle would work out pretty well).   Let me point out I am not saying it wouldn't play any MPG, it just doesn't play high quality mpg's.  Now granted, I was running it on the wireless option, and I was latter told at the store the wired option supported better quality (why wasn't this in the documentation). Which I have some skepticism, as I had actually went into the data store for the media files and modified entries in the media library that allowed the mpg to be played.  The reason that I had to do that is because the file could not be imported by the Media import application that came with the player.  The data store is actually an Access data base in the root directory of the application.  I just went in, looked around the tables and modified the appropriate flags to make the Connected DVD player think it was a valid file.  When I tired to play the high quality mpg, it played the first 5 seconds of the movie, before it became digitized and froze up.  Almost like the processor couldn't handle it.
 
The other thing that was really frustrating is that when I bought it at the Gateway Country Store the sales people were not extremely knowledgeable about the product.  For example, they didn't know that in the latest packaging it didn't come with a PCMCIA network card like it had in the past… that caused an additional irritating trip back to purchase a compatible card.  They also didn't know that it supported MPG4 through a software and flash upgrade found on the Gateway site.