Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

ASP.NET Projects to WAP conversion


:P
On this page:

Over the last few weeks I’ve heard from a couple of friends who decided to update their ASP.NET 2.0 projects to Web Application Projects and ended up running into a number of problems in the process. The process of converting existing projects is probably not as straight forward as it could be and it involves a few manual steps of copying files and moving things around in the projects which are not directly obvious.

 

Scott Guthrie has some excellent walk throughs that talk about the basics, but I suspect most people don’t have such simplistic projects that they are dealing with. Most projects have rather large number of files scattered through various directories that contain a variety of code and support files etc.

 

I hadn’t tried a conversion recently after the new integration with Visual Studio 2005 SP1, so thought for kicks I’d run through the exercise of converting this application that is of medium complexity and has several levels of inheritance in the page layout and see how it goes. When I tried this previous with early versions of WAP this particular application was rather problematic to port, although others I ported over where somewhat easier. So here’s take two <s>…

 

For reference the app has about 50 pages about 10 user controls, several Web Services, several themes and several master pages in a  theming Master Page theming mechanism that matches the style Themes.

 

While there are a few issues to watch out for, overall the process went pretty smooth. It took about a half an hour to do the full conversion, so here’s a quick review of what did and how I got around a few of the errors that popped up in getting the installation to run. The points here are mostly bullet points – if you want to look at a real step by step walk through use Scott’s tutorials and come back here if you run into problems <s>.

 

 

Copy files into the new WAP Project from Explorer

The approach I took is like Scott suggests which is to create a new WAP project and then copy the existing ASPX and other files into the project. This is fairly straight forward – you can just drag and drop the source files from a directory into the new project. Make sure you only copy files/directories that contain code related files – unlike stock projects WAP projects should only contain compilable files and don’t contain everything such as images/css etc. Do copy all of your APP_ folders though as these are special folders including your APP_CODE folder which WAP will later rename.

 

Set References

Once you’ve added the files to the project, go ahead and make sure you add all references you have defined in the references section. Unlike stock projects, WAP uses real project references and doesn’t use values stored in web.config. If you’re not sure what references you have defined look in your Web.config and match the settings from the <compilation><assemblies> references. In addition, you’ll also want to add explicit references to anything that lives in your BIN folder so that the compiler can find them. Again, unlike stock projects WAP projects don’t use the ASP.NET compiler but use standard compilation so anything that is compiled must be referenced by the project directly.

 

Convert to Web Application

At this point you can go ahead and actually convert your ASP.NET pages and controls etc. to the new WAP format by using the Convert to Web Application option. Right click on the project node in Solution Explorer and let ‘er rip. This can take a bit on a large project. Note any errors that show up in the error window.

 

It’s very likely that you will run into some issues at this point.

 

You may find that you see page conversion errors. This might especially be true with pages that have inherited based classes other than Page.

 

 

APP_CODE and the Compile Option

The first problem is one of the converter: Stock projects require that all Code for a Web Project is stored in the APP_CODE folder. WAP recognizes the special APP_CODE folder but requires that it is renamed and so it creates a OLD_APP_CODE folder. It creates the folder containing files marked with a Build Action - Content (select the source code file and look at properties). The file should be marked with Build Action – Compile. Without this none of your APP_CODE related code will be recognized most likely causing big problems for compilation.

 

Namespace and Control References

Stock ASP.NET projects have a nifty feature that allows you to store included namespaces and control references in web.config. When stored there these namespaces and control references are automatically included for you so you don’t have to explicitly define them. WAP doesn’t support this, so if you used this feature you will now get compilation errors. No big deal – you just have to add the control references explicitly to ASPX/ASCX etc. pages and add namespaces to codebehind pages.

 

Web.Config settings pointing at APP_CODE

If you have HTTP Handlers or Modules and you’ve defined them in the application you may find that you’ve explicitly pointed them at source code in your APP_CODE directory. For example:

 

<httpHandlers>

  <add verb="*" path="*.wws"
      
type="Westwind.WebStore.PageRedirectorHTTPHandler,App_Code"/>

</httpHandlers>

 

You need to now point this at the output assembly of your project:

 

<httpHandlers>

  <add verb="*" path="*.wws"
      
type="Westwind.WebStore.PageRedirectorHTTPHandler,WestWindWebStore"/>

</httpHandlers>

 

And at this point the app was up and running and working 100% under WAP.

 

Compilation is different with WAP!

When you switch to WAP ASP.NET is no longer compiling your application completely. Only the CodeBehind of the actual pages in the project are compiled by the compiler in VS.NET – the ASPX pages are handled at runtime by the ASP.NET compiler. This means when you compile a WAP project you get no warnings/errors reported in your ASPX/ASCX/MASTER page markup code for expressions or embedded code. Only CodeBehind compiles.

 

If you still want full compilation of your project – perhaps optionally – you can still use Web Deployment Projects. There’s been some confusion about WDP in that it is not part of Visual Studio 2005 SP1. WDP continues to be a separate download.

 

I’m still hopeful that Microsoft at one point will provide direct single assembly compilation as part of the ASP.NET compiler and provide an option to run that from a WAP project to ‘double check’ a complete application compile. We’ll see.

 

 

This is by no means an exhaustive review of issues, but these are some of the things I've run into in several conversions.  

Posted in ASP.NET  

The Voices of Reason


 

A Continuous Learner's Weblog
February 27, 2007

# A Continuous Learner's Weblog: Links (2/26/2007)


Web Forms
April 25, 2007

# ASP.NET Forums - Calling Static methods on Code Behind class of WebForm


ASP.NET Forums
May 17, 2007

# Calling Static methods on Code Behind class of WebForm - ASP.NET Forums

# DotNetSlackers: ASP.NET Projects to WAP conversion


mk
June 11, 2008

# re: ASP.NET Projects to WAP conversion

I have tryed to convert a website to a WAP but i stuck with a problem with my Dataset.
After the conversion i have to set my default namespace before all my dataset...

dsTest.TestDataTable tlTest;
dsTestTableAdapters.TestTableAdapter daTest= new dsTestTableAdapters.TestTableAdapter();
tlTest = daTest.GetData();

Error 29 ..Missing assembly bla bla bla....

I have to do this

MyNameSpace.dsTest.TestDataTable tlTest;
MyNameSpacedsTestTableAdapters.TestTableAdapter daTest= new MyNameSpacedsTestTableAdapters.TestTableAdapter();
tlTest = daTest.GetData();

That works!

why??? IM stuck!

moki
July 28, 2008

# re: ASP.NET Projects to WAP conversion

and i want to know if i dont use the code from APP_CODE but use bla bla .dll .How could I make the projects to wap conversion?

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024