Naveen's Weblog

Bridge to future

Posts Tagged ‘ASP.NET’

Hosting WCF and ASP.NET application under same virtual directory in IIS

Posted by codingsense on October 28, 2009


I had created a WCF service and an ASP.NET application which would consume the service, I hosted both in separate virtual directories and it was working very fine. After some days and lots of changes I noticed that the dlls and other common files used in both WCF and application, had to be replaced in both the virtual directories to synchronize them.

So I planned to see if it’s possible to host both the application under same virtual directory and got a solution of merging the web.Config files of both the application. Now I have to replace the necessary assemblies or files in only one virtual directory and it has made my job lot easier.

Following are the steps that were followed.
Note: At the end I removed the WCF virtual directory and made my ASP.Net virtual directory to host both the application.

  • Copy the required files (Except Config file) from WCF virtual directory and place them appropriately in the structure in virtual directory. (Eg: .svc file in the main folder and other required dlls into the bin folder)
  • Now we have all files in appropriate locations, just we need to do is to merge the web.config files to contain both Service as well as client configuration.
  • Open the web.Config file that was in WCF virtual directory and copy the <services> tag and <behaviour> tag with all its contents.
  • WebConfig

  • Open the web.Config file of application and paste the copied contents in the <system.serviceModel> tag.
  • Copy the new path of the service by brosing the .svc file from IIS manager (inetmgr.exe) Note: If it wont run successfully check for required setting for the service in web.Config.
  • In the web.Config in the virtual directory and change the address of all the endpoints to point to the new location of service.
  • Run the main application.

After following the above procedure I successfully hosted both applications under same virtual directory.

If you have any problem while following the steps or any other problem related to WCF or IIS you can please share it with me.

Happy Learning 🙂
Naveen Prabhu


Posted in WCF | Tagged: , , | Leave a Comment »

IIS 6.0 proper Installation and hosting ASP.NET(2.0/3.0/3.5) projects

Posted by codingsense on October 15, 2009

For successful hosting of ASP.Net projects in IIS 6.0 we need to install required components and configure IIS properly. The following sections give the steps that need to be followed while Installation and hosting.

There are 3 steps that should be followed they are,

1. Installation of IIS on Windows server 2003
2. Registering 2.0
3. Hosting Asp.Net projects
3.1 Create virtual Directory
3.2 Creating our own Application Pool
3.3 Change Setting of Virtual Directory
3.4 Set ASP.Net version for the project

1) Installation of IIS on Windows server 2003

Open add remove programs from control panel
Click Add/Remove windows component on the left bar
When all the components are listed double click on Application Server
Select Application Server Console, ASP.NET and Message Queuing
Double click on Internet Information Services (IIS)
Select All the check Boxes and click OK
Click Ok -> Next -> Starts installing the selected components -> Click Finish

2) Registering 2.0

Open command Prompt (Click start menu -> Run -> enter cmd -> Press enter)
Navigate to folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
Enter aspnet_regiis -i
Press enter

3) Hosting Asp.Net projects
Open IIS Manger (Click start menu -> run -> inetmgr -> Press enter).

3.1) Create virtual Directory
Expand Local computer -> Web Sites
Right click on Default web site -> New -> virtual Directory
Give the name of the virtual directory that you need to create
Click Next
Select the folder where you have published ASP.NET project
Click Next
Select Read and Read Scripts (Such as ASP)
Click Finish

3.2) Creating our own Application Pool
This will be used if you have hosted projects that are built with framework of different versions
Right click on Application Pools -> New
Enter a name for your Application Pool
If you are running many framework of differn then for each one framework you have to create different Application pool

3.3) Change Setting of Virtual Directory
Right click on created Virtual directory -> Properties
Select Virtual Directory Tab
Check Directory browsing if you need to enable browsing your directory
In Application Settings group -> Click Create
Select Execute permissions -> Script Only
Select Application Pool -> Select the created Application Pool Select depending on your framework version

3.4) Set ASP.Net version
Click ASP.NET tab
In ASP.NET version select 2.0.50727

Note: You need to set ASP.NET version as 2.0.50727 for all the projects built in framework versions 2/3.0/3.5.

This will install all the components and setting that are required to run ASP.NET 2/3/3.5 projects on IIS 6.0.

If any other issues feel free to post a comment.

Happy Learning 🙂
Naveen Prabhu

Posted in IIS | Tagged: , | 5 Comments »