Marco Bellinaso's Blog

 Tuesday, December 20, 2005

In the last couple of days I've been experimenting a lot with deploying the ASP.NET 2.0 sample website I'm building fom my next Wrox book. I mean deployment in the real world, to a real hosting space. I used aspnet_compiler.exe to precompile the site so that it's faster to load on first request, and especially to protect my code (at least a little bit) from prying eyes. Then I executed aspnet_merge.exe to merge all generated assemblies into a single file that's easier to deploy. The documentation I found most useful was the two DOC files that you can download from this page, which cover the aspnet_compiler.exe and aspnet_merge.exe command-line tools, plus the Visual Studio 2005 Web Deployment Projects add-in. This addin provides an intuitive and easy-to-use UI for the aforementioned tools. For example, you can choose the compile all source files and even the markup of the .aspx, .ascx and the other ASP.NET files into a single assembly by ticking a couple of checkboxes and building the project.

While using these tools to compile and deploy the site I ran into a problem (and its solution) that I thought would be good to report here. When you create web pages in VS2005, it doesn't create the code-beside class into a default namespace, like VS.NET2003 did. So, unless you add it manually, all your pages' code-beside classes will be defined within the default ASP namespace. Now you may wonder: what happens if I have multiple pages called default.aspx, with a _default code-beside class? This is actually my situation, as I have a default.aspx under the site's root folder, another one under /admin, and some others. This wasn't a problem while testing the site with the standard in-place precompilation, because these pages' classes get dynamically compiled into separate assemblies, and therefore there isn't any duplicate type name. Everything was fine until I tried to compile all site into a single assembly (if done manually from the command line, this corresponds to the -o switch of the aspnet_merge.exe tool, in case you're wondering); guess what, in that case the built fails, because aspnet_merge tries to merge into the same assembly multiple ASP._default types! Once the problem became clear, the solution was simple: add an explicit namespace to the pages (in both the .cs/.vb class file, and the .aspx file referencing it through the inherits attribute) that is different for different folders, so that there could be two Default.aspx pages compiled into SampleSite._Default and SampleSite.Admin._Default.

The bottom line is: always use explicit namespaces for all your pages and controls, even if it bothers you to add it manually! In the following couple of days I'll be posting more details about the sample site, and will actually provide a link to explore it online (including the admin section!). Stay tuned.

12/20/2005 8:48:49 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [1]  | 
 Wednesday, November 30, 2005

Hello everybody, and welcome to my blog! My name is Marco Bellinaso, and some of you may recognize me as one of the authors for a number of Wrox Press books, among which is ASP.NET Website Programming. I've written some articles on online and print programming magazine such as MSDN Magazine, MSDN Online, Visual Studio Magazine and ASP Today. Besides teaching how to write code, I do actually write some real code, and you find some examples in the commercial tools and products listed here on the site: Form Maximizer, CodeBox, VBMaximizer and MB ActiveX Gallery. My main area of expertise is web programming with ASP.NET and related technologies (including SharePoint 2003 (WSS and Portal), SQL Server, Enterprise Services, scripting and more), but I don't snob Windows Forms programming...when strictly required :-). I've also written most of the engine that runs the .Net2TheMax site...so while Francesco takes care of most of the content updates, I'm the one to blame if you get unexpected errors or other problems with the site (ehm...I really hope that's not the case :-D). Community-related works apart, I'm a senior developer, consultant and teacher for Code Architects Srl, an Italian firm founded by Francesco Balena and Giuseppe Dimauro, the two Microsoft RDs for Italy.

Currently, my principal occupation is finishing my new book, i.e. Wrox's ASP.NET Website Programming version 2.0. This time the book is a solo project, and I'm rewriting it completely from scratch. The general approach (Problem - Design - Solution) is quite the same, but 100% of the code is pure .NET 2.0. The solution is now much more integrated, functional and feature-rich than the first edition, and the sample site being built is actually a real-world site that you may sell to customers nearly as-is. A big difference from the previous book is that I'll set apart much more pages for introducing new ASP.NET 2.0 features such as master pages, themes, membership, navigation controls, new binding controls, web parts, localization etc. Right now I'm finishing the code for the Forums module, and very complete modules for managing users, articles, photo galleries, polls and newsletters are already there. In the next days I'll start to post more details about the sample site, and some significant screenshots. In my plan the site will be released publicly, and I will continue to support it after the book is published. I hope it will make a great example for web developers (new and not-so-new)...but I'll leave it to you to judge the code and the book. :-)

Besides keeping you updated about the book's progress status, I want to post tips & tricks I discover during the development, bugs & problems with the framework (a very very rare circumstance, hopefully), and opinions about the developer-world in general. From time to time I also plan to use this space to ask for your opinions and suggestions about the design, implementation and usefulness of ideas and projects I work on. What? This will make it an egoistic blog? Well, I'll try to keep it balanced. :-)

11/30/2005 3:24:52 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 
Get RSS/Atom Feed
RSS 2.0 | Atom 1.0
Search in the blog
Archive
<December 2005>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Categories

Powered by: newtelligence dasBlog 1.8.5223.1