<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>OOP - There It Is - 2.0 Conversion</title>
    <link>http://www.vpsw.com/blogbaby/</link>
    <description>A Very Practical Blog</description>
    <language>en-us</language>
    <copyright>Dean Fiala</copyright>
    <lastBuildDate>Thu, 18 Jan 2007 03:29:44 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>dfiala@vpsw.com</managingEditor>
    <webMaster>dfiala@vpsw.com</webMaster>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=3a714537-4f53-46da-af87-d52921f773e7</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=3a714537-4f53-46da-af87-d52921f773e7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Under ASP.NET 1.1, the ASP.NET engine is
not (by default) responsible for the application's image, style sheet, and javascript
files. These are served up directly by IIS. ASP.NET can be made responsible for these
file types by playing with the ISAPI file mappings and maybe creating an HttpHandler
or two.<br /><br />
This changes under ASP.NET 2.0.  The ASP.NET engine has responsibility for all
these file types and is called when a request for one is made. 
<br /><br />
So what?  The files get served, the application works, who cares if IIS or ASP.NET
does the work?<br /><br />
In many applications it wouldn't matter, but what happens if the application has been
secured in web.config like so...<br /><br />
&lt;authorization&gt;<br />
   &lt;deny users="?" /&gt;<br />
&lt;/authorization&gt;<br /><br />
... and an anonymous user tries to access the site and gets redirected to the login
page?<br /><br />
Under 1.1, since IIS was responsible for the css, javascript and image files, it wouldn't
matter -- the page would be served as expected, showing all the images and properly
referencing any stylesheets or script files.<br /><br />
Under 2.0, the anonymous user would see an unstyled page with blank image boxes. Any
javascript calls to referenced files won't work either. Why? Because ASP.NET isn't
going to serve up anything but the login page to an anonymous user -- because that
is what it was told to do.<br /><br />
This is great for security, but can be a little frustrating when you KNOW you put
the right path in for that image, and KNOW that the all h1 elements should be hot
pink  and all you see is an unformatted mess.<br /><br />
Fortunately it is very easy to work around this so the public pages on a secured site
show up properly.  All that needs to be done is to tell the application that
anonymous users are allowed to access the content in certain folders. This can be
done using a <a href="http://msdn2.microsoft.com/en-us/library/b6x6shw7.aspx">location
element</a> or two in the web.config file.  The following one allows anonymous
users to access content in the unsecured_images folder...<br /><br />
&lt;location path="unsecured_images"&gt;<br />
    &lt;system.web&gt;<br />
      &lt;authorization&gt;<br />
        &lt;allow users="*" /&gt;<br />
      &lt;/authorization&gt;<br />
    &lt;/system.web&gt;<br />
  &lt;/location&gt;<br /><br />
That's all there is to it. 
<br /><br /><br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=3a714537-4f53-46da-af87-d52921f773e7" /></body>
      <title>Before You Go Insane...</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</link>
      <pubDate>Thu, 18 Jan 2007 03:29:44 GMT</pubDate>
      <description>Under ASP.NET 1.1, the ASP.NET engine is not (by default) responsible for the application's image, style sheet, and javascript files. These are served up directly by IIS. ASP.NET can be made responsible for these file types by playing with the ISAPI file mappings and maybe creating an HttpHandler or two.&lt;br&gt;
&lt;br&gt;
This changes under ASP.NET 2.0.&amp;nbsp; The ASP.NET engine has responsibility for all
these file types and is called when a request for one is made. 
&lt;br&gt;
&lt;br&gt;
So what?&amp;nbsp; The files get served, the application works, who cares if IIS or ASP.NET
does the work?&lt;br&gt;
&lt;br&gt;
In many applications it wouldn't matter, but what happens if the application has been
secured in web.config like so...&lt;br&gt;
&lt;br&gt;
&amp;lt;authorization&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;deny users="?" /&amp;gt;&lt;br&gt;
&amp;lt;/authorization&amp;gt;&lt;br&gt;
&lt;br&gt;
... and an anonymous user tries to access the site and gets redirected to the login
page?&lt;br&gt;
&lt;br&gt;
Under 1.1, since IIS was responsible for the css, javascript and image files, it wouldn't
matter -- the page would be served as expected, showing all the images and properly
referencing any stylesheets or script files.&lt;br&gt;
&lt;br&gt;
Under 2.0, the anonymous user would see an unstyled page with blank image boxes. Any
javascript calls to referenced files won't work either. Why? Because ASP.NET isn't
going to serve up anything but the login page to an anonymous user -- because that
is what it was told to do.&lt;br&gt;
&lt;br&gt;
This is great for security, but can be a little frustrating when you KNOW you put
the right path in for that image, and KNOW that the all h1 elements should be hot
pink&amp;nbsp; and all you see is an unformatted mess.&lt;br&gt;
&lt;br&gt;
Fortunately it is very easy to work around this so the public pages on a secured site
show up properly.&amp;nbsp; All that needs to be done is to tell the application that
anonymous users are allowed to access the content in certain folders. This can be
done using a &lt;a href="http://msdn2.microsoft.com/en-us/library/b6x6shw7.aspx"&gt;location
element&lt;/a&gt; or two in the web.config file.&amp;nbsp; The following one allows anonymous
users to access content in the unsecured_images folder...&lt;br&gt;
&lt;br&gt;
&amp;lt;location path="unsecured_images"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;system.web&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;authorization&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow users="*" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/authorization&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/system.web&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/location&amp;gt;&lt;br&gt;
&lt;br&gt;
That's all there is to it. 
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=3a714537-4f53-46da-af87-d52921f773e7" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
      <category>2.0 Conversion</category>
      <category>web.config</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=27013c9f-ec59-4762-9569-462a9b6b6653</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=27013c9f-ec59-4762-9569-462a9b6b6653</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Finally! .NET 2.0 has been out for a year.  Finally found the time to move
our <a href="http://www.celadonlabs.com/probeity/login.aspx?demo=true">main application</a> to
2.0. It's been a bit of an adventure.  There are 12 class libraries, 2 server
control assemblies, a service, a web app and various utilities.  Two of the class
libraries are in C++, one managed, one native. The truly insane can read about the <a href="http://community.strongcoders.com/blogs/vpsw/archive/2006/11/14/a-journey-to-c-land.aspx">little
odyssey through those assemblies</a>.  Everything else is written in VB.NET.  
<br /><br />
The VB.NET class libraries converted easily.  The only issue was in the few classes
that performed XSL Transformations where I had to change a couple of deprecated method
calls.  <a href="http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx">These
were no surprise</a>.  Other than that there were only warnings for untyped functions
or parameters (very naughty, and one of the dangers of working in VB with OPTION STRICT
OFF) and a surprising number of unused local variables.  
<br /><br />
The web application was a lot trickier than anticipated.  There are some <a href="http://msdn2.microsoft.com/en-us/library/ms379586%28VS.80%29.aspx">fundamental
differences</a> between 1.1 and 2.0 web applications. One of the significant changes
is in the coding model.  2.0 makes use of partial classes, so that a single class
can be created from separate files, this cleans some things up.  There are no
longer control declarations in the code-behind file, but it is a change.  
</p>
        <p>
Here is a very <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/conversionissuesasp_net.asp">handy
resource</a> that discusses most of the issues you will run into when converting from
1.1 to 2.0.  
<br /><br />
In the standard out-of-the-box VS2005, the project file for web applications has also
gone the way of the dodo, you create Web Site Projects.  Everything in the project
tree gets put into the application. Fortunately, there is a feature to exclude files,
which you will use. Since the Web Site Project includes ALL the files in
the directory tree, files that you excluded in your 1.1 project will suddenly reappear
like uncompilable ghosts in the 2.0 version. The other annoying "feature" is that
these projects spew forth an assembly for every folder in your application, and couple
of others for good measure, and the files are randomly named.  Hello deployment
fun -- I'm sure there's good reason for this, but it is not intuitively obvious, it
seems friggin' nutty.
</p>
        <p>
This application model had been fine for the smaller projects I had
converted, and I figured I would discover a way to deal with the assembly vomit, so
I pushed on assuming that I was moments away from having a our application working
in 2.0. 
</p>
        <p>
But it was not to be, this web application pushed the Web Site Project model over
the cliff of despair.
</p>
        <p>
The application has around 60 pages, 15 classes and 15 user controls spread
amongst 10 directories. Most of the heavy lifting is done in the underlying libraries. I
didn't think it was that large until I tried to compile it.  In VS 2003, it was
up and running in under a minute, in VS2005 it was 5+ minutes, and the sucker was
crashing every time I changed the base web page class that the pages inherited from. 
I lived with this for about a day, googling while it compiled or restarted, toggling
various settings, swearing and pruning previously exlcuded and unused pages ruthlessly.  
</p>
        <p>
After one seemingly eternal cycle of rebooting, I seriously considered asking
for a quad-core super box or retreating back to 1.1.  I decided to take one
more look around the web for a solution and I stumbled across this <a href="http://www.simple-talk.com/dotnet/asp.net/asp.net-2.0-and-vs-2005---you-win-some,-you-lose-some/">article</a>,
which in turn led me to discover an alternate model to this lunancy, the <a href="http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx">Web
Application Project</a>! It was the old 1.1 compilation model, complete with
a single assembly output -- hooray.  It required some VS update installations
and yet another conversion from my original 1.1 application, but in a few hours I
had a quickly compiling application.  Some testing and a small victory dance
later, and it was time to start ripping out the facacta hand-rolled page templates
and putting in the master pages!
</p>
        <p>
        </p>
        <hr />
        <br />
Just a reminder kids, always use source code control, especially when undertaking
a conversion.  It makes mistakes almost painless and recovery simple! 
<br /><hr size="2" width="100%" /><br /><font color="#ff0000">UPDATE:</font>  MS has shipped the <a href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx">first
service pack for VS 2005</a>. This includes the Web Application Projects. If you have
previously installed the Web Application update, you will have to uninstall it before
installing the service pack.<br /><p></p><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=27013c9f-ec59-4762-9569-462a9b6b6653" /></body>
      <title>Moving On Up to 2.0</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</link>
      <pubDate>Thu, 21 Dec 2006 04:04:59 GMT</pubDate>
      <description>&lt;p&gt;
Finally! .NET 2.0 has been out for a year.&amp;nbsp; Finally found the time&amp;nbsp;to move
our &lt;a href="http://www.celadonlabs.com/probeity/login.aspx?demo=true"&gt;main application&lt;/a&gt; to
2.0. It's been a bit of an adventure.&amp;nbsp; There are 12 class libraries, 2 server
control assemblies, a service, a web app and various utilities.&amp;nbsp; Two of the class
libraries are in C++, one managed, one native. The truly insane can read about the &lt;a href="http://community.strongcoders.com/blogs/vpsw/archive/2006/11/14/a-journey-to-c-land.aspx"&gt;little
odyssey through those assemblies&lt;/a&gt;.&amp;nbsp; Everything else is written in VB.NET.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
The VB.NET class libraries converted easily.&amp;nbsp; The only issue was in the few classes
that performed XSL Transformations where I had to change a couple of deprecated method
calls.&amp;nbsp; &lt;a href="http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx"&gt;These
were no surprise&lt;/a&gt;.&amp;nbsp; Other than that there were only warnings for untyped functions
or parameters (very naughty, and one of the dangers of working in VB with OPTION STRICT
OFF) and a surprising number of unused local variables.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
The web application was a&amp;nbsp;lot trickier than anticipated.&amp;nbsp; There are some &lt;a href="http://msdn2.microsoft.com/en-us/library/ms379586%28VS.80%29.aspx"&gt;fundamental
differences&lt;/a&gt; between 1.1 and 2.0 web applications. One of the significant changes
is in the coding model.&amp;nbsp; 2.0 makes use of partial classes, so that a single class
can be created from separate files, this cleans some things up.&amp;nbsp; There are no
longer control declarations in the code-behind file, but it is a change.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Here is a very &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/conversionissuesasp_net.asp"&gt;handy
resource&lt;/a&gt; that discusses most of the issues you will run into when converting from
1.1 to 2.0.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
In the standard out-of-the-box VS2005, the project file for web applications has also
gone the way of the dodo, you create Web Site Projects.&amp;nbsp; Everything in the project
tree gets put into the application. Fortunately, there is a feature to exclude files,
which you will use. Since the Web Site Project includes&amp;nbsp;ALL the&amp;nbsp;files in
the directory tree, files that you excluded in your 1.1 project will suddenly reappear
like uncompilable ghosts in the 2.0 version. The other annoying "feature" is that
these projects spew forth an assembly for every folder in your application, and couple
of others for good measure, and the files are randomly named.&amp;nbsp; Hello deployment
fun -- I'm sure there's good reason for this, but it is not intuitively obvious, it
seems friggin' nutty.
&lt;/p&gt;
&lt;p&gt;
This&amp;nbsp;application&amp;nbsp;model&amp;nbsp;had been fine for the smaller projects I had
converted, and I figured I would discover a way to deal with the assembly vomit, so
I pushed on assuming that I was moments away from having a our application working
in 2.0. 
&lt;/p&gt;
&lt;p&gt;
But it was not to be, this web application pushed&amp;nbsp;the Web Site Project model&amp;nbsp;over
the cliff of despair.
&lt;/p&gt;
&lt;p&gt;
The&amp;nbsp;application has around 60 pages, 15 classes&amp;nbsp;and 15 user controls spread
amongst 10 directories.&amp;nbsp;Most of the heavy lifting is done in the underlying libraries.&amp;nbsp;I
didn't think it was that large until I tried to compile it.&amp;nbsp; In VS 2003, it was
up and running in under a minute, in VS2005 it was 5+ minutes, and the sucker was
crashing every time I changed the base web page class that the pages inherited from.&amp;nbsp;
I lived with this for about a day, googling while it compiled or restarted, toggling
various settings, swearing and pruning previously exlcuded and unused pages ruthlessly.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
After one seemingly eternal cycle of rebooting, I&amp;nbsp;seriously considered asking
for a quad-core super box or retreating back to 1.1.&amp;nbsp;&amp;nbsp;I decided to take&amp;nbsp;one
more look around the web&amp;nbsp;for a solution and&amp;nbsp;I stumbled across this &lt;a href="http://www.simple-talk.com/dotnet/asp.net/asp.net-2.0-and-vs-2005---you-win-some,-you-lose-some/"&gt;article&lt;/a&gt;,
which in turn led me to&amp;nbsp;discover an alternate model to this lunancy, the &lt;a href="http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx"&gt;Web
Application Project&lt;/a&gt;!&amp;nbsp;It was the old 1.1 compilation model, complete with
a single assembly output -- hooray.&amp;nbsp; It required some VS update installations
and yet another conversion from my original 1.1 application, but in a few hours I
had a quickly compiling application.&amp;nbsp; Some testing and&amp;nbsp;a small victory dance
later, and it was time to start ripping out the facacta hand-rolled page templates
and putting in the master pages!
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;br&gt;
Just a reminder kids, always use source code control, especially when undertaking
a conversion.&amp;nbsp; It makes mistakes almost painless and recovery simple! 
&lt;br&gt;
&lt;hr size="2" width="100%"&gt;
&lt;br&gt;
&lt;font color="#ff0000"&gt;UPDATE:&lt;/font&gt;&amp;nbsp; MS has shipped the &lt;a href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx"&gt;first
service pack for VS 2005&lt;/a&gt;. This includes the Web Application Projects. If you have
previously installed the Web Application update, you will have to uninstall it before
installing the service pack.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=27013c9f-ec59-4762-9569-462a9b6b6653" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
      <category>2.0 Conversion</category>
    </item>
  </channel>
</rss>