Blog Home  Home RSS 2.0 Atom 1.0 CDF  
The Efficient Coder - Wednesday, November 05, 2008
There has got to be a better way of communicating with our computers!
 
 Wednesday, November 05, 2008

In all my web sites my pages inherit from a custom base page that inherits from System.Web.UI.Page and overrides OnError.  This method then uses Server.GetLastError() to get the exception generated by the offending code.  At this point, it's probably too late to do anything about it, but at least I can take a snap shot of the current user context, log that information present a friendly message to the user.  Although the bug made it into production at least it's not happening 200 times a day and I don't know about.

A good portion of my site is driven by web services via AJAX and as I start to implement Silverlight for a few sophisticated UI components, I'm relying more and more on web services.  My problem until now was I didn't have any sort of catch-all that notified me about problem in a web service call.

After a bit of research I found something called a SoapExtension in the System.Web.Services.Protocols namespace.

This provides calls at different points in the processing of the soap message:

We can implement some functionality in the AfterSerialize stage.  If we detect a non-null value in the message.Exception property it's probably safe to assume something bad happened within the web service.

The final step is to register this in the web.config file.

In addition SoapExtensions can be associated with specific methods via attributes.  This might be interesting to provide an interesting solution for attaching custom authentication and authorization.

-ec

11/5/2008 8:27:49 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]   ASP.NET  |  Trackback
 Monday, November 03, 2008

I've finally found a good excuse to implement something using Silverlight 2.0 within my web product.  After spending about 3-4 hours attempting to get my Silverlight app to talk to a local web service, I found out something that hopefully will save you some time.  First a little about my environment.  I'm using IIS 7.0 on a 64 bit machine.  I have IIS setup with two sites for my Silverlight development, the first hosts my web service, the second hosts the web site containing my Silverlight application.  I have my hosts file setup as follows

127.0.0.1   webservice
127.0.0.1   website

Then in IIS I bind the the web sites to those host names.

After setting up the clientaccesspolicy.xml file in my webservice site to allow Silverlight to access I just couldn't get my Silverlight app to talk to my web service.  I tried this in both IE and Firefox with no luck.  After doing a little testing, I found it worked when I used the development web server (I think this was formally called cassini) it also seemed to work when when I used the host name "localhost".  Next I fired up fiddler and watched the network traffic.  Anytime I used cassini or local host, the clientaccesspolicy.xml was downloaded and the call to the web service succeeded.  If I tried this through my site, no request was made.

After trying a number of things I found I was able to get this working by opening the security settings within Internet Explorer

Tools->Internet Options->Security Tab, then click on Local Intranet and add my two sites.  This seemed to do the trick for both Internet Explorer and Firefox.

Hope this saves you a bit of time

-ec 

11/3/2008 8:50:58 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]   ASP.NET | Silverlight  |  Trackback
 Thursday, October 23, 2008

From George S. Patton

Good tactics can save even the worst strategy. Bad tactics will destroy even the best strategy.

Let's relate that to software:

Strategy = Architecture

Tactics = Programming

If you have a poor architecture, it can be made up for by great programmers, but if you have poor programmers implementing software on a great architecture results will probably still be poor. 

-ec

10/23/2008 6:35:40 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]   Extreme Programming | Moments of Clarity  |  Trackback
 Tuesday, October 21, 2008

I belive the following is accurate for developing 95% of business applications:

  1. People buy software to solve problems, that can be making their life easier, making money or providing pleasure (don’t read too much in to that J)
  2. Features enable solutions to problems.
  3. When we write software, we build features.
  4. With the right level of abstraction there is a common and finite set of features to be implemented in code.
  5. Applications should be built by tailoring features to solve a user problem. 
  6. If tailoring features has to be done by writing code, so be it, but this is very costly in terms of time and money.
  7. It’s preferable to have this done via configuration.

-ec

 

10/21/2008 4:38:03 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]   Software Engineering  |  Trackback
 Monday, July 21, 2008

I have the need in my application for users to upload many different types of documents and images.  Currently I have two ways of doing this; the first is to save to a set of directories organzied by user in a file system, the second is in the data base.  Neither of these are really ideal for many reasons that I'm sure you recognize.  To resolve this issue, I built a component that extends the ASP.NET file upload control to allow you to save files to the Amazon Simple Storage Servce (S3).  I've released the source code and component with an open source license, so you can download this and use in your projects as well.  The download as well as documentation can be found at http://downloads.slsys.net/S3FileUpload/Default.aspx.

Enjoy and feedback is appreciated!

-ec

7/21/2008 6:39:54 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]   ASP.NET  |  Trackback
 Friday, July 04, 2008

As a developer, I appreciate the complexity and I'm trying really hard to like Vista (SP1) but sometimes it's a bit on the frustrating side...

Then after loading Visual Studio .NET and trying to do some work, the reason became obvious

:-)

Anyway, after rebooting all is well.

-ec

7/4/2008 3:38:34 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]   Lighter Side  |  Trackback
 Thursday, July 03, 2008

Well if you saw my garage, you know I should be the last one talking about this, maybe I use up all my organizational energy on the code I write?

Anyway, in a project I've been working over the past year or so, I've been using the ASP.NET Themeing concept along with CSS to build a "skinnable" product.  Skinning will for the most part be accomplished via CSS.  As I've been adding features, I've sort-of hacked together the required CSS as a new feature was added.  These were organized into different areas, and named appropriately, but as I started to build additional themes, it just got fairly complex making sure everything got lined up and styles didn’t get messed up in different CSS’s.

 
Here is an example of my original CSS for section of the application, imagine there are about 12 other sections similar to this

/* -------- Edit Panel ------------ */
div.edit-panel
{border:1px solid #AACCEE;text-align:left;width:400px;background-color:white}
div.edit-panel-header
{background-color:#EBF3FB;border-bottom:1px solid #AACBEE;margin:0pt 0pt 6px;padding:3px 6px;}
div.edit-panel-header-tight
{background-color:#EBF3FB;border-bottom:1px solid #AACBEE;padding:3px 6px;}
div.edit-panel-header
span{color:#07519A;font-family:Verdana;font-weight:bold;}
div.edit-panel-header-tight
span{color:#07519A;font-family:Verdana;font-weight:bold;}
div.edit-section
{padding:4px;font-family:Tahoma;font-size:9px}
.edit-section-caption
{display:block;font-weight:bold;padding-left:5px;color:#07519A;font-size:1.2em;font-family:Verdana}
div.edit-section-save-bar
{text-align:right;padding-left:4px;padding-right:3px; padding-bottom:3px}
div.edit-section-save-bar
a {color:#075191;text-decoration:none}
div.edit-section-save-bar
a:hover {color:#075191;text-decoration:underline}
div.edit-section-validation-error
{padding:4px}
div.edit-section-validation-error
span {color:Red;}
.edit-section-input
{border:1px solid #AACCEE; color:#606060 }
.edit-section-textarea
{border:1px solid #AACCEE;width:98%; color:#606060 }
.edit-section-select
{ border:1px solid #AACCEE; color:#606060 }
span.edit-section-required-symbol
{ color:Red;font-size:8pt;font-family:Verdana }
span.edit-section-message-bar-error
{}
span.edit-section-required-symbol
{}
/* -------- Edit Panel ------------ */

So now I wanted to change the color scheme and make things look consistent across the application, how would I know I made all the borders look correctly?  How about all the fonts and or back ground colors, you would have to wade through the noise and hope you got everything.  Although I don’t always succeed, I really try to keep my code organized into certain patterns that is to say if I need to add an event handler to a WebForm, well, I’ve got a #region block in my code and all event handlers get placed in that #region.  So thinking about it, why should CSS be any different?  I adopted the following organizational strategy to make this a bit easier to manage, it’s a little bit longer, but if I want to change colors, I can just work in one area and make sure I get them all right.

 

/* -------- Edit Panel ------------ */
/* Colors */

div.edit-panel
{border:1px solid #AACCEE;background-color:white}
div.edit-panel-header
{background-color:#EBF3FB;border-bottom:1px solid #AACBEE;}
div.edit-panel-header
span{color:#07519A;}
div.edit-panel-header-tight
{background-color:#EBF3FB;border-bottom:1px solid #AACBEE;}
div.edit-panel-header-tight
span{color:#07519A;}
div.edit-section-validation-error
span {color:Red;}
span.edit-section-required-symbol
{ color:Red;}
.edit-section-caption
{color:#07519A;}
.edit-section-input
edit-section-select edit-section-textarea  {border:1px solid #AACCEE; color:#606060 }
div.edit-section-save-bar
a {color:#075191;}
div.edit-section-save-bar
a:hover {color:#075191;}
/* Colors */ 

/* Layout */
div.edit-panel
{text-align:left;width:400px;}
div.edit-panel-header
{margin:0pt 0pt 6px;padding:3px 6px;}
div.edit-panel-header-tight
{padding:3px 6px;}
div.edit-section
{padding:4px;}
.edit-section-textarea
{width:98%;}
.edit-section-caption
{display:block;padding-left:5px;color:#07519A;}
div.edit-section-validation-error
{padding:4px}
div.edit-section-save-bar
{text-align:right;padding-left:4px;padding-right:3px; padding-bottom:3px}
div.edit-section-save-bar
a {text-decoration:none}
div.edit-section-save-bar
a:hover {text-decoration:underline}
/* Layout */ 

/* Fonts */
div.edit-section
{font-family:Tahoma;font-size:9px}
.edit-section-caption
{font-weight:bold;padding-left:5px;color:#07519A;font-size:1.2em;font-family:Verdana}
div.edit-panel-header
span{font-family:Verdana;font-weight:bold;}
div.edit-panel-header-tight
span{font-family:Verdana;font-weight:bold;}
span.edit-section-required-symbol
{font-size:8pt;font-family:Verdana }
/* Fonts */ 

/* Misc */
span.edit-section-message-bar-error
{}
span.edit-section-required-symbol
{}
/* Misc */
/* -------- Edit Panel ------------ */

 
-ec

7/3/2008 10:08:35 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]    |  Trackback
 Thursday, June 26, 2008

In ASP.NET 1.1, if you wanted to upload a file you needed to make sure that you added the following text to your ASP.NET form declaration:

In ASP.NET 2.0 adding a file upload control to the form must have done this behind the scene since this was no longer a requirement.

I've been fighting an issue in my application where the file didn't get uploaded the first time the form was rendered, I have an update panel with a grid that when clicked upon displays the details record.  That detail record then has file upload control, and uses the method I wrote about earlier to upload the file within a control rendered in an Update Panel.

Although I haven't spent the extra time tracking this down to the bits, it's my assumption that the page originally get's rendered without the FileUpload control and the Form doesn't contain the encoding type.  Then when the file upload control does get rendered to the page, it doesn't update the form encoding type attribute.  So the solution is to just add the enctype='multipart/form-data' to the form tag.  This seems to resolve the issue and does indeed make sense.

-ec

 

6/26/2008 8:02:34 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]    |  Trackback
Copyright © 2010 Kevin D. Wolf. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: