September 2005 Entries



As I mentioned in a post about Visual Studio 2005 Beta 2, I recently converted a small ASP.NET 1.1 project to a 2.0 project.  While I had a number of issues with the conversion, there was a change in ASP.NET 2.0 that cost me a bit of time to figure out what happened.

It seems that in ASP.NET 2.0 they have decided to kill ViewState for read only controls (at least the Textbox that I used).  That is, Textboxs for example in 2.0 do not persist their values in Viewstate if they are marked as read only. 

Let us say you have a form and it lists a number of fields.  A couple of those fields you do not want the user editing, but you want them to look about the same as the other fields.  You load the initial values into those form fields in the page_load and filter out the IsPostback so that they are only set on the initial load.  This would fine for normal controls, but if marked Read Only (at least with the textbox control which is the one I tested), it does not retain its values and you must set the value each time.

In .NET 1.1, all the fields that had Viewstate enabled, would have maintained there values through a postback, but not in 2.0.  While this is yet another small, no biggy type problem, it is something to keep a look out for in your future projects.




After having the Visual Studio 2005 Beta 2 for several months, I finally got around to trying out ASP.NET V2.0 and converting a small application over to it.

The conversion did not go too smooth.  The project uses URL Rewriting and a custom form tag to strip the page name from the form action.  The custom form tag allows the page to postback without having the URL in the address bar of the browser expose the true page name the browser is viewing.  An example would be pages:

MyWebSite.com/Home/

MyWebSite.com/About/

MyWebSite.com/Services/

In each of these folders is a default page.  When someone uses the Home URL above, they only see the directory folder as shown, they do not ever see "MyWebSite.com/Home/Default.aspx".  This may not sound like much of a biggy and you might wonder why I even bother.  One reason is that I can switch the page type (asp..net, .php, .asp or even .htm) at any time without breaking people's or search engine links to the specific page.  This allows the web site to remain flexible to change and use any technology without breaking links.

The problem with this method is mostly due to a bug in Visual Studio that does not like the custom Form tags (a tag of a class derived from HtmlForm).  Whenever I open a webform in the designer that contains a custom tag, it spews out an error:

--

Unable to cast object of type 'System.Web.UI.Design.HtmlIntrinsicControlDesigner' to type 'System.Web.UI.Design.ControlDesigner'

--

While the designer in VS has a problem with these tags, ASP.NET 2.0 does not and the forms function as they did in .Net 1.1.  This is an annoying problem and forces me to manually change the form tags ("<skm:form></skm:form>") back to normal ("<form></form) when I want to edit the form in the designer and then change them back when I am finished.  As you might guess, this is a pain every time you want to edit an ASPX page.

Another thing VS does not like is the method I use to maintain multiple web sites on my local Windows 2003 server development machine.  I currently use a multi-homed method with names in a custom hosts file.  The link below will give you more information on exactly what I use:

http://hintsandtips.com/ShowPost/42/hat.aspx

The reason I use this method is that I may easily have multiple websites on my server, each as root webs that I can access by the name of the domain minus the .com.  For an example, at any time, I can point my browser to "http://rockymoore" and it will pull up my local version of this web site.  Makes it very easy to keep track of the sites.

The problem is that every time I go to run a page in the debugger it gives me the message:

--

Unable to start debugging on the web server.  You were not connected because a duplicate name exists on the network.  Go to System in Control Panel to change the computer name and try again.

--

It does not seem to like the host file aliases for the web names.  Of course, this was not a problem in VS.NET 2003 which worked great for all the above.

Supposedly, this is a bug in VS.NET 2005 and is said to be fixed in the final version when released.  Until then however, I have to do an "Attach Process" and attach the debugger to the currently running web session to do any debugging.  This again, is quite a pain if you have to debug/testing often.

I have noticed that html editor in the IDE is does not always render in a WYSIWYG manner all the time, but it is much better that VS.NET 2003's editor. 

One thing I really do not like is the method they are displaying non-displayable components on a web form.  In the past version, they would display a panel area below the page that would list all the components you added to the form (such as a dataset).  In the new version they place those items on your actual form in your markup.  Talk about ugly and hard to work with if you are laying out a page.  They were sleeping on this one for sure!


The quick remedy to this is to change the "View/Non-Visual Controls" menu option to be not checked so that you see the page like it should be.  Of course, to edit the components you drop on a page, you have to enable this again to see them.

Another little jewel I noticed and spent way too much time solving, was an error from vs.net when I tried to compile the web application that it could not find or load a web form's codeBehind (CodeFile) page.  I spent many hours figuring out that, the real error was usually down the list and that this error was a ghost.  Talk about wasted time!

Overall, though, this tool has a great deal of promise.  There are many nice enhancements along with generation of XHTML forms instead HTML 4.0 transitional of VS.NET 2003.   I could go on with a list of features, but those are listed all over the net.  I just wanted to give people a little heads up of possible problems you might run into.




Microsoft is having a busy day today!  It is hard to keep up with all that is coming out their door now, can hardly imagine what it will be like as Windows Vista starts to roll out!

Here are a few links of stuff I am checking into today.  Lots to cover and play around with.  So much for being productive today :)   I have already spent more than a couple hours and there is no end in sight ;)

http://msdn.microsoft.com/msn/

http://atlas.asp.net/

http://msdn.microsoft.com/netframework/future/linq/default.aspx

http://www.microsoft.com/max/

http://msdn.microsoft.com/vcsharp/future/

http://msdn.microsoft.com/vbasic/future/

I sure feel sorry for my little brain trying to find more room for all of this! :)  Looks like it is time to dig up the almost $3k for a new MSDN subscription..




There is output compression built into IIS 5.0 and later, but it is disabled by default.  Below is instructions how to enable it.

With HTTP Compression enabled, IIS will compress with “gzip” or “deflate” the file types you list as it feeds the page to the browser.  On the client end it will decompress the file and will act as if it read the entire uncompressed file.  This is built into most late model browsers.  If it feeds a page to a browser which does not support compression, it will send out the uncompressed page.

I have this setup on my sites and it can make a dramatic difference in page size and load time on the client side, but you will take a CPU hit on the server.

For many sites I use DotNetNuke, but at this time the solpart menu javascript is 72,822 bytes. With compression enabled compress down to 16,107 bytes, big savings!  The main aspx page on one of my sites is currently at 26,264 bytes, but with compression it only has to send out 5,747 bytes, a 79% savings!

A good tool to check your site and the possible savings if you use compression is at:

http://www.port80software.com/support/tools/compresscheck.asp

Directions:

Here is a simple batch file that can enable compression and set a few optional values at the same time.


cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true


cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcFileExtensions "htm" "html" "txt"
cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcFileExtensions "htm" "html" "txt"

cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcScriptFileExtensions "asp" "aspx" "dll" "exe" "asmx" "doc" "asmx" "js" "css"


cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcScriptFileExtensions "asp" "aspx" "dll" "exe" "asmx" "doc" "asmx" "js" "css"

cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcDynamicCompressionLevel "9"
cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcDynamicCompressionLevel "9"

cscript adsutil.vbs SET W3SVC/Filters/Compression/Deflate/HcOnDemandCompLevel "9"
cscript adsutil.vbs SET W3SVC/Filters/Compression/gzip/HcOnDemandCompLevel "9"


**These commands modify your IIS settings in your metabase.xml, use at your own risk.  Be sure to backup your IIS config before using this so that you can always restore it if you should desire.

You can place that batch file into your \inetpub\adminscripts directory and call it to enable compression of static and dynamic files.  You would edit the list of file types to the specific ones you wish to have compression enable to handle.

More information on enabling compress can be found at:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q322603




My original .Text blog handles all my posts and any topic.  I decided to split the blog up and have just a Dev blog.

Over the next few weeks I will begin to get some posts in here.

One of the posts I plan for this space is a new DNN generic data store module I am woking on that allows a person to design new modules without the need of specific database data stores (tables, stored procedures, etc).  This means modules will be able to function on different databases without change.  Anyway, more on this coming shortly along with the free code.  You might want to subscribe to this feed to keep and eye of for it.

Another topic I will cover is the split of of my original .Text blog and a few issues and solutions I found converting a single based .Text blog to a multiple blog based system along with some other tips.

Well, more to come soon..  Keep an eye out!