Archive for the ‘Web Hosting’ Category

Designing a division modal (Div Modal) Box Overlay

Designing a division modal (Div Modal) Box Overlay

Lets start with the designing of the overlay, before procedding with the overlay i would like to introduce why this overlay is named as such. as this overlay is designed using <div> tags used inside html programming language so i named it as such (you are free to name it as like you want)

there are four steps to design this overlay.

1.  Making an div overlay

2. giving it some attractive look

3. functioning of the overlay

4. Calling overlay on some action using mouse

here we goes with the design of the overlay :-

1.  Making an div overlay

<div id=”modalPage”>
<div>
</div>
<div>
<div>
<div><a href=”test.html”>X</a></div>
<div>
<p>i want to show the text box values here….</p>
</div>
</div>
</div>
</div>

Test.html is the name of the page where we are designign the overlay

2. giving it some attractive look

<style type=”text/css”>
body
{
margin: 0px;
}
#modalPage
{
display: none;
position: absolute;
width: 100%;
height: 100%;
top: 0px; left: 0px;
}
.modalBackground
{
filter: Alpha(Opacity=40); -moz-opacity:0.4; opacity: 0.4;
width: 100%; height: 100%; background-color: #999999;
position: absolute;
z-index: 500;
top: 0px; left: 0px;
}
.modalContainer
{
position: absolute;
width: 300px;
left: 50%;
top: 50%;
z-index: 750;
}
.modal
{
background-color: white;
border: solid 4px black; position: relative;
top: -150px;
left: -150px;
z-index: 1000;
width: 300px;
height: 300px;
padding: 0px;
}
.modalTop
{
width: 292px;
background-color: #000099;
padding: 4px;
color: #ffffff;
text-align: right;
text-decoration: none;
}
.modalTop a, .modalTop a:visited
{
color: #ffffff;
}
.modalBody
{
padding: 10px;
}
</style>

3. functioning of the overlay

<script language=”javascript” type=”text/javascript”>
function revealModal(divID)
{
window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
document.getElementById(divID).style.display = “block”;
document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID)
{
document.getElementById(divID).style.display = “none”;
}

</script>

4. Calling overlay on some action using mouse

<body>
<input id=”Button1″ type=”button” value=”Click here to be naughty” onclick=”revealModal(‘modalPage’)” />
</body>

so going with the pattern we used here to design the overlay the page layout and design using html programming language can be given as follows :-

<html>
<title>Divison Modal (Div Modal) Box</title>
<head>
<div id=”modalPage”>
<div>
</div>
<div>
<div>
<div><a href=”test.html”>X</a></div>
<div>
<p>i want to show the text box values here….</p>
</div>
</div>
</div>
</div>
<style type=”text/css”>
body
{
margin: 0px;
}
#modalPage
{
display: none;
position: absolute;
width: 100%;
height: 100%;
top: 0px; left: 0px;
}
.modalBackground
{
filter: Alpha(Opacity=40); -moz-opacity:0.4; opacity: 0.4;
width: 100%; height: 100%; background-color: #999999;
position: absolute;
z-index: 500;
top: 0px; left: 0px;
}
.modalContainer
{
position: absolute;
width: 300px;
left: 50%;
top: 50%;
z-index: 750;
}
.modal
{
background-color: white;
border: solid 4px black; position: relative;
top: -150px;
left: -150px;
z-index: 1000;
width: 300px;
height: 300px;
padding: 0px;
}
.modalTop
{
width: 292px;
background-color: #000099;
padding: 4px;
color: #ffffff;
text-align: right;
text-decoration: none;
}
.modalTop a, .modalTop a:visited
{
color: #ffffff;
}
.modalBody
{
padding: 10px;
}
</style>
<script language=”javascript” type=”text/javascript”>
function revealModal(divID)
{
window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
document.getElementById(divID).style.display = “block”;
document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID)
{
document.getElementById(divID).style.display = “none”;
}

</script>
</head>
<body>
<input id=”Button1″ type=”button” value=”Click here to be naughty” onclick=”revealModal(‘modalPage’)” />
</body>
</html>

and here is the div overlay looks like the design

that’s all ..

Can I convert my WSP into a WAP, without starting from scratch?

Differences between Web Site Projects (WSP) and Web Application Projects (WAP) are highlighted in blogs such as this one. Based on that, if you feel a WAP would be better for your particular needs than a WSP, but have already created a WSP, you may be asking yourself, “Can I convert my WSP into a WAP, without starting from scratch?”.

This posting explains how to convert an existing Web Site Project to a Web Application Project in Visual Studio 2010. The most striking differences to a Web Site Project are that WAPs have a project file to include and exclude files, and compile to a single assembly.

The guidelines below include several of the basic steps detailed in the Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio. This is an excellent topic to review as it discusses some specific issues you may encounter which were discovered in previous versions of Visual Studio (VS). Please keep in mind while reading it that it is based on a WSP to WAP conversion using previous versions of Visual Studio.

Let’s get started.

Open and Verify your Visual Studio Web Site Project
Before converting your WSP to a WAP, you should open it in Visual Studio and verify that is it working correctly.  This will help prevent the need to research errors that have nothing to do with the conversion process.

  1. In the File menu, click Open Web Site.

  2. The Open Web Site dialog box is displayed.

  3. Select the project folder that you want to open, and then click Open.

  4. In the Build menu, click Build Web Site.

  5. In the Debug menu, click Start Debugging. Alternatively, you can press F5.

  6. Verify your project compiles and runs as expected

Create a new, empty Visual Studio WAP
A good strategy for converting a WSP to a WAP is to create a new, blank Visual Studio Web Application Project in a separate directory, but in the same solution. This avoids changing any part of the existing Web site files. It also allows you to copy existing functionality and files into the new WAP easily, within the same Visual Studio instance.

  1. In the File menu, click Add, and then click New Project.

  2. The Add New Project dialog box is displayed.

  3. In the Installed Templates section of the Add New Project dialog box, expand the language that you want to use, and then select Web to display the Web-related templates.

  4. Select Empty ASP.NET Web Application.

  5. Type values for NameLocation, and then click OK to create the Web Application Project.

  6. After the project has been created, delete the Web.config file that is created automatically.

Set Project / Assembly References
If the WSP required additional project or assembly references, you need to add them to the WAP. You can see the list of default references associated with the new (empty) Visual Studio Web Application Project under the References node in Solution Explorer.

  1. In the Solution Explorer, make sure Show All Files is turned on.

  2. In the Solution Explorer, right-click References, and then click Add Reference.

  3. The Add Reference dialog box is displayed.

  4. Select the reference that you have already added in the Web Site Project and then click OK.

  5. Note: To help prevent errors, add references to the Web Application Project for assemblies that existed in the \bin folder of the WSP.

 

Copy and Convert the App_Code folder from the Web Site Project to the Web Application Project
In WSPs, the files in the App_Code folder are all compiled together and then referenced (automatically) as a “dll” by all other files in the WSP. In WAPs, this is not the case. All code is compiled together as one .dll. I’ve found that copying the App_Code folder over first and converting it to the WAP model helps to head off some dependency issues which could arise if one copied the entire site, converted, and then tried to compile.

  1. In the Solution Explorer, copy the entire App_Code folder from the WSP to the WAP

  2. In the Solution Explorerselect the WAP’s root node; right-click, select Convert to Web Application

  3. You will see our standard Convert to Web Application confirmation dialog.  Select “Yes” to this dialog.

  4. The App_Code folder should now be renamed to Old_App_Code folder

  5. Note: Do NOT name it back. As mentioned above, in the WAP model all code will be compiled into one assembly. At runtime, ASP.NET doesn’t know what type of project model you have created and will take anything in the “App_Code” folder and create a dynamic assembly for it, thereby causing “could not load type” exceptions as there would be duplicate types exists in two assemblies (the one for the VS web application and the one for App_Code).  Learn more about why App_Code folder does not work well with WAPs.

  6. Compile the WAP

  7. If you see an error, the most likely causes are:

    1. Missing assembly reference. See the section above to add missing references to your project.

    2. Files marked with Build Action = Content instead of Build Action = Compile. Any file you want compiled should be marked as such.

    3. To set the Build Action property:

      1. Select the file in the Solution Explorer

      2. Press F4 (Brings up the File’s Property Grid)

      3. Look at the Build Action property. Change as necessary.

Copy and Convert the remaining Files and Folders from the WSP to the WAP
Once your Old_App_Code folder is compiled (by compiling your WAP in the step above), your WAP will have an assembly in the \bin directory. This will make it easier for the remaining files you are copying over to successfully compile, especially if they reference or use code in the files contained within that folder.

  1. Select the remaining files / folders from the WSP project and copy them into the WAP.

  2. Make sure not to copy the App_Code folder again.

  3. In the Solution Explorer, right click the root node of the WAP and select Convert to Web Application.

    1. Don’t worry, this won’t affect (or try to reconvert) any files or the Old_App_Code folder you have already converted.

  4. Note: This will cause VS to automatically generate a .designer.cs (or .vb) file for each page, user-control, and master page in the project. Additionally, each .aspx/.ascx will be modified to use the ‘Codebehind’ instead of the ‘CodeFile’ attribute in the Page directive.

    1. Example of the ‘CodeFile’ to ‘Codebehind’ change

      1. WSP file:  <%@ Page Title=”Home Page” Language=”C#” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

      2. Converted WAP file:  <%@ Page Title=”Home Page” Language=”C#” Inherits=”_Default” Codebehind=”Default.aspx.cs” %>

Compile your WAP
After all the files have been added and converted, you should build your project again to see if there are any compilation errors. At this point, some of the most likely causes of errors are:

  1. Code files set with Build Action = Content. These should be changed to Compile. Refer to the above section.

  2. Missing project or assembly references. See above for steps for adding project or assembly references.

  3. Class name collisions. In the WSP model, each .aspx and associated codefile was compiled together as a separate, individual unit. Therefore, one could have files such as foo\widget.ascx.cs and bar\widget.ascx.cs where the classes were the same. Once these files are moved to a WAP and all compiled together, class name collisions occur with errors something like, “has multiple definitions with identical signatures”. If this occurs, unique class names should be created.

Run your WAP
After completing the above steps and you have a WAP which successfully compiles, you are ready to try running your application. One of the most common problems I’ve seen encountered is the “Unknown server tag ‘SomeTag: Control’ (as it applies to user controls and such)”. This can be corrected in one of two ways.

  1. Add or modify the register directive on the page that is using the control. This will only register it for this specific page.

    1. <%@ Register Namespace”namespace the control is in” TagPrefix=”SomeTag” Assembly=”Name of dll compiled into the \bin folder” %>

  2. Register the control in the Web.config, making it available to all pages in the project

    1. In the <pages><controls> section add the following:

    2. <add tagPrefix=”SomeTag” namespace=”namespace the control is in” assembly=” Name of dll compiled into the \bin folder” />

Hope this helps!

Manually Installing Php on any system

This section contains instructions for manually installing and configuring PHP on Microsoft Windows. For the instructions on how to use PHP installer to setup and configure PHP and a web server on Windows refer to Windows Installer (PHP 5.2 and later).

Selecting and downloading the PHP distribution package

Download the PHP zip binary distribution from » PHP for Windows: Binaries and Sources. There are several different versions of the zip package – chose the version that is suitable for the web server being used:

If PHP is used with IIS then choose PHP 5.3 VC9 Non Thread Safe or PHP 5.2 VC6 Non Thread Safe;

If PHP is used with IIS7 or greater and PHP 5.3+, then the VC9 binaries of PHP should be used.

If PHP is used with Apache 1 or Apache 2 then choose PHP 5.3 VC6 or PHP 5.2 VC6.

Note:

VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the » Microsoft 2008 C++ Runtime (x86) or the » Microsoft 2008 C++ Runtime (x64) installed.

The PHP package structure and content

Unpack the content of the zip archive into a directory of your choice, for example C:\PHP\. The directory and file structure extracted from the zip will look as below:

Example #1 PHP 5 package structure

c:\php
|
+–dev
| |
| |-php5ts.lib — php5.lib in non thread safe version
|
+–ext — extension DLLs for PHP
| |
| |-php_bz2.dll
| |
| |-php_cpdf.dll
| |
| |-…
|
+–extras — empty
|
+–pear — initial copy of PEAR
|
|
|-go-pear.bat — PEAR setup script
|
|-…
|
|-php-cgi.exe — CGI executable
|
|-php-win.exe — executes scripts without an opened command prompt
|
|-php.exe — Command line PHP executable (CLI)
|
|-…
|
|-php.ini-development — default php.ini settings
|
|-php.ini-production — recommended php.ini settings
|
|-php5apache2_2.dll — does not exist in non thread safe version
|
|-php5apache2_2_filter.dll — does not exist in non thread safe version
|
|-…
|
|-php5ts.dll — core PHP DLL ( php5.dll in non thread safe version)
|
|-…

Below is the list of the modules and executables included in the PHP zip distribution:

go-pear.bat – the PEAR setup script. Refer to » Installation (PEAR) for more details.

php-cgi.exe – CGI executable that can be used when running PHP on IIS via CGI or FastCGI.

php-win.exe – the PHP executable for executing PHP scripts without using a command line window (for example PHP applications that use Windows GUI).

php.exe – the PHP executable for executing PHP scripts within a command line interface (CLI).

php5apache2_2.dll – Apache 2.2.X module.

php5apache2_2_filter.dll – Apache 2.2.X filter.

Changing the php.ini file

After the php package content has been extracted, copy the php.ini-production into php.ini in the same folder. If necessary, it is also possible to place the php.ini into any other location of your choice but that will require additional configuration steps as described in PHP Configuration.

The php.ini file tells PHP how to configure itself, and how to work with the environment that it runs in. Here are a number of settings for the php.ini file that help PHP work better with Windows. Some of these are optional. There are many other directives that may be relevant to your environment – refer to the list of php.ini directives for more information.

Required directives:

extension_dir = – The extension_dir needs to point to the directory where PHP extensions files are stored. The path can be absolute (i.e. “C:\PHP\ext”) or relative (i.e. “.\ext”). Extensions that are listed lower in the php.ini file need to be located in the extension_dir.

extension = xxxxx.dll – For each extension you wish to enable, you need a corresponding “extension=” directive that tells PHP which extensions in the extension_dir to load at startup time.

log_errors = On – PHP has an error logging facility that can be used to send errors to a file, or to a service (i.e. syslog) and works in conjunction with the error_log directive below. When running under IIS, the log_errors should be enabled, with a valid error_log.

error_log = – The error_log needs to specify the absolute, or relative path to the file where PHP errors should be logged. This file needs to be writable for the web server. The most common places for this file are in various TEMP directories, for example “C:\inetpub\temp\php-errors.log”.

cgi.force_redirect = 0 – This directive is required for running under IIS. It is a directory security facility required by many other web servers. However, enabling it under IIS will cause the PHP engine to fail on Windows.

cgi.fix_pathinfo = 1 – This lets PHP access real path info following the CGI Spec. The IIS FastCGI implementation needs this set.

fastcgi.impersonate = 1 – FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.

fastcgi.logging = 0 – FastCGI logging should be disabled on IIS. If it is left enabled, then any messages of any class are treated by FastCGI as error conditions which will cause IIS to generate an HTTP 500 exception.

Optional directives

max_execution_time = ## – This directive tells PHP the maximum amount of time that it can spend executing any given script. The default for this is 30 seconds. Increase the value of this directive if PHP application take long time to execute.

memory_limit = ###M – The amount of memory available for the PHP process, in Megabytes. The default is 128, which is fine for most PHP applications. Some of the more complex ones might need more.

display_errors = Off – This directive tells PHP whether to include any error messages in the stream that it returns to the Web server. If this is set to “On”, then PHP will send whichever classes of errors that you define with the error_reporting directive back to web server as part of the error stream. For security reasons it is recommended to set it to “Off” on production servers in order not to reveal any security sensitive information that is often included in the error messages.

open_basedir = , e.g. openbasedir=”C:\inetpub\wwwroot;C:\inetpub\temp”. This directive specified the directory paths where PHP is allowed to perform file system operations. Any file operation outside of the specified paths will result in an error. This directive is especially useful for locking down the PHP installation in shared hosting environments to prevent PHP scripts from accessing any files outside of the web site’s root directory.

upload_max_filesize = ###M and post_max_size = ###M – The maximum allowed size of an uploaded file and post data respectively. The values of these directives should be increased if PHP applications need to perform large uploads, such as for example photos or video files.

PHP is now setup on your system. The next step is to choose a web server, and enable it to run PHP. Choose a web server from the table of contents.

In addition to running PHP via a web server, PHP can run from the command line just like a .BAT script. See Command Line PHP on Microsoft Windows for further details.

How to call a PHP Script from ASP.NET C# and View Its response?

Hi guys,
I was wondering on net abt , how to call a PHP Script from ASP.NET C#, then found a simple solution.
Actually, Its nothing but calling any other ASP.NET C# file.
The script is as follow:
Basically I wanted to send User Id and Account ID and then process the table:

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(“http://rover.geodesic.net/wcv1/php/ProcessTrans.php?userid=&#8221; + item.Value + “&accountid=” + item.Key + “&type=stock”);

// Set the ‘Timeout’ property in Milliseconds.
myRequest.Timeout = 600000;//10 mintutes
myRequest.Method = “GET”;
HttpWebResponse newStream = (HttpWebResponse)myRequest.GetResponse();

if ((newStream.ContentLength > 0))
{
System.IO.StreamReader str = new System.IO.StreamReader(newStream.GetResponseStream());
Response.Write(str.ReadToEnd());
if (str != null) str.Close();
}

The small changes I did was, I multi threaded the process, as i was taking more time to execute the PHP page “ProcessTrans.php”;
In above example, Data has been sent in “GET”
If you want to Post Data to remote Web Page using HttpWebRequest :

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(“http://rover.geodesic.net/wcv1/php/ProcessTrans.php?userid=&#8221; + item.Value + “&accountid=” + item.Key + “&type=stock”);
request.Method = “POST”;
request.ContentLength = data.Length;
request.ContentType = “application/x-www-form-urlencoded”;
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tmp = reader.ReadToEnd();
response.Close();
Response.Write(tmp);
}

It might not work if the site you’re trying to stream is protected by authentication. If it’s Windows/NTLM Authentication and your account has privileges on the site, try using:
request.Credentials = CredentialCache.DefaultCredentials;
after the create request.

Ref: http://www.worldofasp.net/tut/WebRequest/Working_with_HttpWebRequest_and_HttpWebResponse_in_ASPNET_114.aspx

regards,

ASP.NET: Use VB.NET and C# within the App_Code folder

When I was creating my new blog site, I choose to write it in C#. I had a problem with the App_Code folder because I had some code in VB.NET code and some C# code I needed to put in there. I didn’t want to rewrite my VB.NET code in the App_Code folder just so I could write the rest of the code for the site in C#.
Luckily, the ASP.NET Team had already thought about just this kind of circumstance. They implemented a way to partition the App_Code folder into sub-folders, one for each set of code files written in the same programming language. Awesome, I didn’t have to spend a couple hours converting code from VB.NET to C#!
The below works with ASP.NET 2.0 and later.
Even if you don’t use multiple different programming languages for your code files in the App_Code folder, you could use this feature to organize your sets of related code files into sub-folders.
Step 1: Add the following Sample lines to the web.config in the form of tags.

configuration
    system.web
        compilation
            codeSubDirectories
                add directoryName="VB_Code"/
                add directoryName="CS_Code"/
            /codeSubDirectories
        /compilation
    /system.web
/configuration

Step 2: Create a sub-folder in the App_Code folder for each language you want to support.
For Example:

App_Code
/App_Code/VB_Code
/App_Code/CS_Code
App_Code

Step 3: Place your VB.NET code in the VB_Code folder and place C# code in the CS_Code folder.

Converting a Web Site Project to a Web Application Project

Differences between Web Site Projects (WSP) and Web Application Projects (WAP) are highlighted in blogs such as this one. Based on that, if you feel a WAP would be better for your particular needs than a WSP, but have already created a WSP, you may be asking yourself, “Can I convert my WSP into a WAP, without starting from scratch?”.

This posting explains how to convert an existing Web Site Project to a Web Application Project in Visual Studio 2010. The most striking differences to a Web Site Project are that WAPs have a project file to include and exclude files, and compile to a single assembly.

The guidelines below include several of the basic steps detailed in the Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio. This is an excellent topic to review as it discusses some specific issues you may encounter which were discovered in previous versions of Visual Studio (VS). Please keep in mind while reading it that it is based on a WSP to WAP conversion using previous versions of Visual Studio.

Let’s get started.

Open and Verify your Visual Studio Web Site Project
Before converting your WSP to a WAP, you should open it in Visual Studio and verify that is it working correctly.  This will help prevent the need to research errors that have nothing to do with the conversion process.

  1. In the File menu, click Open Web Site.
  2. The Open Web Site dialog box is displayed.
  3. Select the project folder that you want to open, and then click Open.
  4. In the Build menu, click Build Web Site.
  5. In the Debug menu, click Start Debugging. Alternatively, you can press F5.
  6. Verify your project compiles and runs as expected

Create a new, empty Visual Studio WAP
A good strategy for converting a WSP to a WAP is to create a new, blank Visual Studio Web Application Project in a separate directory, but in the same solution. This avoids changing any part of the existing Web site files. It also allows you to copy existing functionality and files into the new WAP easily, within the same Visual Studio instance.

  1. In the File menu, click Add, and then click New Project.
  2. The Add New Project dialog box is displayed.
  3. In the Installed Templates section of the Add New Project dialog box, expand the language that you want to use, and then select Web to display the Web-related templates.
  4. Select Empty ASP.NET Web Application.
  5. Type values for NameLocation, and then click OK to create the Web Application Project.
  6. After the project has been created, delete the Web.config file that is created automatically.

WSPandWAP

Set Project / Assembly References
If the WSP required additional project or assembly references, you need to add them to the WAP. You can see the list of default references associated with the new (empty) Visual Studio Web Application Project under the References node in Solution Explorer.

  1. In the Solution Explorer, make sure Show All Files is turned on.
  2. In the Solution Explorer, right-click References, and then click Add Reference.
  3. The Add Reference dialog box is displayed.
  4. Select the reference that you have already added in the Web Site Project and then click OK.
  5. Note: To help prevent errors, add references to the Web Application Project for assemblies that existed in the \bin folder of the WSP.

AddRef

Copy and Convert the App_Code folder from the Web Site Project to the Web Application Project
In WSPs, the files in the App_Code folder are all compiled together and then referenced (automatically) as a “dll” by all other files in the WSP. In WAPs, this is not the case. All code is compiled together as one .dll. I’ve found that copying the App_Code folder over first and converting it to the WAP model helps to head off some dependency issues which could arise if one copied the entire site, converted, and then tried to compile.

  1. In the Solution Explorer, copy the entire App_Code folder from the WSP to the WAP
  2. In the Solution Explorerselect the WAP’s root node; right-click, select Convert to Web Application
  3. You will see our standard Convert to Web Application confirmation dialog.  Select “Yes” to this dialog.
  4. The App_Code folder should now be renamed to Old_App_Code folder
  5. Note: Do NOT name it back. As mentioned above, in the WAP model all code will be compiled into one assembly. At runtime, ASP.NET doesn’t know what type of project model you have created and will take anything in the “App_Code” folder and create a dynamic assembly for it, thereby causing “could not load type” exceptions as there would be duplicate types exists in two assemblies (the one for the VS web application and the one for App_Code).  Learn more about why App_Code folder does not work well with WAPs.
  6. Compile the WAP
  7. If you see an error, the most likely causes are:
    1. Missing assembly reference. See the section above to add missing references to your project.
    2. Files marked with Build Action = Content instead of Build Action = Compile. Any file you want compiled should be marked as such.
    3. To set the Build Action property:
      1. Select the file in the Solution Explorer
      2. Press F4 (Brings up the File’s Property Grid)
      3. Look at the Build Action property. Change as necessary.

converttowap

Copy and Convert the remaining Files and Folders from the WSP to the WAP
Once your Old_App_Code folder is compiled (by compiling your WAP in the step above), your WAP will have an assembly in the \bin directory. This will make it easier for the remaining files you are copying over to successfully compile, especially if they reference or use code in the files contained within that folder.

  1. Select the remaining files / folders from the WSP project and copy them into the WAP.
  2. Make sure not to copy the App_Code folder again.
  3. In the Solution Explorer, right click the root node of the WAP and select Convert to Web Application.
    1. Don’t worry, this won’t affect (or try to reconvert) any files or the Old_App_Code folder you have already converted.
  4. Note: This will cause VS to automatically generate a .designer.cs (or .vb) file for each page, user-control, and master page in the project. Additionally, each .aspx/.ascx will be modified to use the ‘Codebehind’ instead of the ‘CodeFile’ attribute in the Page directive.
    1. Example of the ‘CodeFile’ to ‘Codebehind’ change
      1. WSP file:  <%@ Page Title=”Home Page” Language=”C#” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
      2. Converted WAP file:  <%@ Page Title=”Home Page” Language=”C#” Inherits=”_Default” Codebehind=”Default.aspx.cs” %>

convertedfiles

Compile your WAP
After all the files have been added and converted, you should build your project again to see if there are any compilation errors. At this point, some of the most likely causes of errors are:

  1. Code files set with Build Action = Content. These should be changed to Compile. Refer to the above section.
  2. Missing project or assembly references. See above for steps for adding project or assembly references.
  3. Class name collisions. In the WSP model, each .aspx and associated codefile was compiled together as a separate, individual unit. Therefore, one could have files such as foo\widget.ascx.cs and bar\widget.ascx.cs where the classes were the same. Once these files are moved to a WAP and all compiled together, class name collisions occur with errors something like, “has multiple definitions with identical signatures”. If this occurs, unique class names should be created.

Run your WAP
After completing the above steps and you have a WAP which successfully compiles, you are ready to try running your application. One of the most common problems I’ve seen encountered is the “Unknown server tag ‘SomeTag: Control’ (as it applies to user controls and such)”. This can be corrected in one of two ways.

  1. Add or modify the register directive on the page that is using the control. This will only register it for this specific page.
    1. <%@ Register Namespace”namespace the control is in” TagPrefix=”SomeTag” Assembly=”Name of dll compiled into the \bin folder” %>
  2. Register the control in the Web.config, making it available to all pages in the project
    1. In the <pages><controls> section add the following:
    2. <add tagPrefix=”SomeTag” namespace=”namespace the control is in” assembly=” Name of dll compiled into the \bin folder” />


Hope this helps!

Convert “App_Code” to DLL

Question :

I have inherited a .NET 2.0 web project. It consists of a root site,
and 3 sub directories. Ideally these are seperate projects/websites. The root is a customer-
facing one, and the other 3 are for admin, and supervisor use. I want to break the existing project (all websites treated as one) into 4 separate websites. Unfortunately they all share the “App_code” directory, which contains
common classes to all 4 sites. Can anyone advise on how I can make the App_code a shared component in
4 websites, so that I can rebuild the entire app as 4 projects, which
will speed up development, and make it more robust (90% of development
and fixes go into the public site, why rebuild the other 3 every
time ?

Answer :

Create a new class library project (in the appropriate language) and copy
the App_Code files into that project. Run it until you can compile, as there
may be some web libs you need to reference, esp. if there is not a good
separation of concerns (likely considering you have library material in
App_Code).

After it compiles, take one of the websites and exclude everything in the
App_Code folder that you have moved. Make a reference to the new library.

Now go through and correct the using (C#) or Imports (vb) statements for
your project. Once you have a compile, consider it a test build and have
someone from QA (if you have QA) test that build thoroughly. Consider it
suspect, because someone may have tied in some config elements that are not
pulling properly into the lib, etc.

As it is being tested, go to another site and do the same. Rinse and repeat
until all sites are thoroughly clean and tested. Then, go back and delete
the excluded files.

NOTE: If you are using source control (you are, right), you can branch the
build before doing the switcheroo and delete instead of exclude at the first
step. It is unlikely you are going back. But, if you are, you still have the
old branch to go back to.

%d bloggers like this: