IIS 7.5 and IIS 8.0 European Hosting

BLOG about IIS 7.5 Hosting, IIS 8.0 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

IIS Hosting Europe - HostForLIFE :: How To Remove IIS On Windows Server?

clock March 15, 2023 08:14 by author Peter

In today's article you will learn how to remove Internet Information Services 8 (IIS8) on Windows Server.

Step 1
First of all login to your Windows Server 2012 as Administrator by entering your password. After logging in your Server Manager will open automatically, if it doesn't then open it by clicking on the first button in the task bar.

As you open the Server Manager this window will be opened:

Step 2
On the Server manager you will see that IIS is already installed.

To remove the IIS go to the Manage option on the upper right hand corner and click on "Remove Rolls and Features".

Step 3
Now a Window will be opened that will inform you that you are going to removing the section. Just click on "Next" to proceed.

After that you must select a Server from the Server Pool. Since I have only one Server in this article, my default Server is Automatically selected.

Step 4
Once you click Next you will get a list (Rolls) from which click on the Web Server (IIS).

Now click "Next", then one more Window will open that will ask for permission to remove the features.

Step 5
You can select the features that are associated with IIS to be removed.

After clicking Next you must give permission to restart the server automatically if it's considered necessary, then click on "Next".

Step 6
Click on the "Remove" button and the process will begin.

When the removal process has completed your Windows Server 2012 will be restarted; that's because earlier you had given permission to do the restart.

Step 7
After restarting it will automatically show that the removal process had completed successfully.

You can also check this on the Flag that is present on the above right hand corner. Click on the Flag and following confirmation will be shown,

IIS Hosting Europe - HostForLIFE :: Create FTP Site Using IIS 7.5

clock March 7, 2023 07:24 by author Peter

Let's follow the below steps to create an FTP site.

Open IIS manager, click on Sites and then click Add FTP site,

Give a name and specify physical path that has content to be shared, click Next.

We can specify an IP address and port number on which the FTP site is  to be hosted, select No SSL option. Default port for FTP is 21. We can select a SSL certificate, if it needs to be secured. Click Next.

We can specify authentication as anonymous [no authentication needed] or basic [need to supply credentials for accessing FTP]. We can set authorization rules like read-only for anonymous users or read-write for specific users or groups. Click Finish.

We can browse FTP site using Windows Explorer, IE or command prompt or tools like FileZilla by using path like ftp://<IP/machine name>/. Since we enabled anonymous authentication, we can login by supplying user name as ftp or anonymous and password as any email address as shown below:

Let’s explore other features of FTP under Features pane of IIS Manager.

FTP Authentication: We can enable/disable anonymous or basic authentication here.
FTP Authorization Rules: We can add rules to set authorization like read-only for anonymous and read-write for specific users or groups.

FTP Current sessions: It will show details of users connected to FTP currently.

FTP Firewall settings at Server level:
Used to set data channel port number and Firewall IP Address. In general, FTP uses two ports. One is for control channel to send commands [default is 21] and other is for data channel [which can be specified here as a range and same need to be opened on Firewall as well] for sending data like file content.

FTP IPv4 Address and Domain Restrictions: Used to restrict\ allow specific IP address for accessing FTP site,

FTP Logging: It is similar to IIS logs, logs information like port number, status code, etc and used for troubleshooting.

FTP Messages: Used to set welcome and exit messages for FTP Users.

FTP Request Filtering: Used to restrict specify file extensions, URLs or commands.

FTP SSL Settings: Used to set SSL and select SSL certificate for secure FTP.

FTP User Isolation: Used to isolate users from accessing other user’s FTP site or home directory.

We can use appcmd.exe tool to create FTP site and set attributes like SSL or authentication using this tool.

Troubleshooting Tips:
    If you are unable to create FTP site, ensure that FTP service is up and running under Windows services.
    If you are getting any authentication problem, ensure that login/anonymous users have sufficient permissions like read or write on physical files.
    We can troubleshoot FTP issues using tools Wireshark and process Monitor.
    Ensure port 21 is opened on Firewall for FTP communication.

I am ending things here, I hope this article will be helpful for all.

IIS Hosting Europe - HostForLIFE :: IIS Hosting of WCF Service

clock February 17, 2023 09:08 by author Peter

First let's create a simple WCF Service.

Step 1
Open Visual Studio and select "File" -> "New" -> "Project...". The following screen will open.

Select WCF Service Library and provide the name of the service as CarService. You can use whatever name for the service as you wish.

You will be able to see the following screen.

Step 2
Delete the Iservice1.cs and Service1.cs files from the project.

Step 3
Then add the two files IProduct.cs (interface file) and ProductService.cs to the project.

Step 4
In IProduct.cs (the interface file) write the following code.
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using System.ServiceModel; 
    namespace NorthwindServices 
        public interface IProducts 
            string GetProductName(); 
             string GetProductQty(); 
             string GetCategoryName(); 

Step 5
In the ProductService.cs file call the Interface file and write the definition of the Interface methods.
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    namespace CarService 
        public class ProductService:IProduct 
            public string GetCarName() 
                return "Ford Figo"; 
            public string GetCarColor() 
                return "Sea Gray"; 
            public string GetQuantity() 
                return "1"; 

Step 6
Now make the following changes in the App.config file.

    <?xml version="1.0" encoding="utf-8" ?> 
        <compilation debug="true" /> 
      <!-- When deploying the service library project, the content of the config file must be added to the host's  
      app.config file. System.Configuration does not support config files for libraries. --> 
          <service name="CarService.ProductService"> 
            <endpoint address="" binding="wsHttpBinding" contract="CarService.IProduct"> 
                <dns value="localhost" /> 
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
                <add           baseAddress="http://localhost:8732/Design_Time_Addresses/CarService/Service1/"/> 
              <!-- To avoid disclosing metadata information,  
              set the value below to false and remove the metadata endpoint above before deployment --> 
              <serviceMetadata httpGetEnabled="True"/> 
              <!-- To receive exception details in faults for debugging purposes,  
              set the value below to true.  Set to false before deployment  
              to avoid disclosing exception information --> 
              <serviceDebug includeExceptionDetailInFaults="False" /> 

As you can see we are using wsHttpBinding. The Service name is <service name="CarService.ProductService"> Contract is contract="CarService.IProduct">,
dns value="localhost" /> & baseaddress is baseAddress="http://localhost:8732/Design_Time_Addresses/CarService/Service1/"/>.

Step 7
Now run the project. If you see the following screen then your WCF Service is working perfectly.

You can invoke the methods and get the results to test the service.

Step 8
Now add the SVC file to the project so that we can use this file later to publish on IIS.
Right-click on the project then select Add -> New Item then select Text File.

Give the name of the file as CarServiceHost.svc

Step 9
Just make the following changes in the SVC file.
    <%@ ServiceHost Service="CarService.ProductService" %>

Step 10
Now build your solution then publish the project.

Give a target location on your hard drive.

Step 11
Now for the important part to host this service on IIS.
Go to Run -> inetmgr.

The following screen will open.

Click on Sites then select Add website.

Give the name of the service as CarService and select Application Pool as ASP.NET v4.0 as in the following:

Give the physical path of the service to the location where you have placed the published SVC file.

Give the port as 7742.

Now just open the browser and for the URL provide "http://localhost:7742/CarServiceHost.svc" or "http://ipaddress:7742/CarServiceHost.svc".The following page will open:

And that's it. You have successfully created and hosted a WCF Service on IIS. You can consume the service in an application and use it.

IIS Hosting Europe - HostForLIFE :: Configure Your ASP.NET Core App For IIS

clock February 2, 2023 06:33 by author Peter

The first thing you will notice when creating a new ASP.NET Core project is that it’s a console application. Your project now contains a Program.cs file, just like a console app, plus the following code:

public class Program
    public static void Main(string[] args)
        var host = new WebHostBuilder()


What is the WebHostBuilder?
All ASP.NET Core applications require a WebHost object that essentially serves as the application and web server. In this case, a WebHostBuilder is used to configure and create the WebHost. You will normally see UseKestrel() and UseIISIntegration() in the WebHostBuilder setup code.

What do these do?
UseKestrel() – Registers the IServer interface for Kestrel as the server that will be used to host your application. In the future, there could be other options, including WebListener which will be Windows only.
UseIISIntegration() – Tells ASP.NET that IIS will be working as a reverse proxy in front of Kestrel and specifies some settings around which port Kestrel should listen on, forward headers and other details.

If you are planning to deploy your application to IIS, UseIISIntegration() is required

What is AspNetCoreModule?
You may have noticed that ASP.NET Core projects create a web.config file. This is only used when deploying your application to IIS and registers the AspNetCoreModule as an HTTP handler.
Default web.config for ASP.NET Core:
<?xml version="1.0" encoding="utf-8"?>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>

AspNetCoreModule handles all incoming traffic to IIS, then acts as the reverse proxy that knows how to hand traffic off to your ASP.NET Core application. You can view the source code of it on GitHub. AspNetCoreModule also ensures that your web application is running and is responsible for starting your process up.

Install .NET Core Windows Server Hosting Bundle
Before you deploy your application, you need to install the .NET Core hosting bundle for IIS – .NET Core runtime, libraries and the ASP.NET Core module for IIS.

After installation, you may need to do a “net stop was /y” and “net start w3svc” to ensure all the changes are picked up for IIS.

Steps to Deploy ASP.NET Core to IIS
Before you deploy, you need to make sure that WebHostBuilder is configured properly for Kestrel and IIS. Your web.config file should also exist and look similar to our example above.

Step 1: Publish to a File Folder

Step 2: Copy Files to Preferred IIS Location
Now you need to copy your publish output to where you want the files to live. If you are deploying to a remote server, you may want to zip up the files and move to the server. If you are deploying to a local dev box, you can copy them locally.

For our example, I am copying the files to C:\inetpub\wwwroot\AspNetCore46

You will notice that with ASP.NET Core, there is no bin folder and it potentially copies over a ton of different .NET DLLs. Your application may also be an EXE file if you are targeting the full .NET Framework. This little sample project had over 100 DLLs in the output.

Step 3: Create Application in IIS
While creating your application in IIS is listed as a single “Step,” you will take multiple actions. First, create a new IIS Application Pool under the .NET CLR version of “No Managed Code”. Since IIS only works as a reverse proxy, it isn’t actually executing any .NET code.

Second, you can create your application under an existing or a new IIS Site. Either way, you will want to pick your new IIS Application Pool and point it to the folder you copied your ASP.NET publish output files to.

Step 4: Load Your App!
At this point, your application should load just fine. If it does not, check the output logging from it. Within your web.config file you define how IIS starts up your ASP.NET Core process. Enable output logging by setting stdoutLogEnabled=true. You may also want to change the log output location as configured in stdoutLogFile. Check out the example web.config before to see where they are set.

Advantages of Using IIS with ASP.NET Core Hosting
Microsoft recommends using IIS with any public facing site for ASP.NET Core hosting. IIS provides additional levels of configurability, management, security and logging, among many other things. One of the big advantages to using IIS is the process management. IIS will automatically start your app and potentially restart it if a crash were to occur. If you were running your ASP.NET Core app as a Windows Service or console app, you would not have that safety net there to start and monitor the process for you.

IIS Hosting Europe - HostForLIFE :: Look at Logging in IIS 7 and IIS 7.5

clock January 27, 2023 07:11 by author Peter

In this article, we will look into the built-in logging features of IIS 7 and 7.5 to log request details. An IIS log is a useful resource to troubleshoot requests. In IIS 7 and 7.5, we can log the details of a request, such as client IP, time taken, response size, cookie and so on into a file. This information helps to find the load on the server in terms of number of requests, size and time taken to serve the request.

Let's open IIS, configure logging for a website and analyze it. We can configure logging at server level or website level. Let's do it at the website level. Go to Default Web Site, go to the Logging feature and click "Enable":

In the following Logging dialog, we can configure the format of the log file, it can be:

  • IIS: IIS log file format is a fixed ASCII text-based format, so you cannot customize it (Can't select fields) and fields are separated by commas.
  • W3C (default format): It is a customizable ASCII text-based format. You can use IIS Manager to select which fields to include in the log file and fields are separated by spaces.
  • NCSA: its log file format is a fixed ASCII text-based format, so you cannot customize it and contains less information than an IIS log format.
  • Custom: ODBC logging is implemented as a custom logging module and helps to log information into ODBC-compliant databases like SQL Server or Microsoft Access.

Select W3C as log format, click on "Select Fields" and choose the fields that need to be logged in the log file.

We can set the location or directory for the log files, set options to create a new log file based on file size, daily or weekly and so on. When we check "Use local time for file naming and rollover" it will use the local server time instead of UTC for log file naming and time for log file rollover. This setting will not affect the time field format of the request logged in the file and uses UTC time format.

Let's may a request to welcome.png present in the Default Web Site and analyze the log file. This log file will be under the path set in the Logging Feature + W3SVC<website identifier>. In my case, it is "C:\inetpub\logs\LogFiles\W3SVC1" and contains the following information:

Most of the fields are self-explanatory and field prefixes have the following meanings:

    s- Server actions
    c- Client actions
    cs- Client-to-server actions
    sc- Server-to-client actions
    sc-bytes - response size
    cs-bytes - request size.

The Time-taken field will show the total time taken to generate the response as well as the time to send the complete response to the client until the last byte. This is done by taking into account the last ACK from the answer to the response. Let's say a request took 5000 milliseconds to generate the response and 3000 milliseconds to send the complete response to the client, so it will show time-taken as 8000 milliseconds.

Most of the preceding logging features are also available on a FTP site as well. In most of the cases, your log file will be very large and can't be analyzed in a notepad. In that scenario, we can use the Log Parser (Available here). Let's install it and open our log file as shown below:

Click on New Query from File Menu and select Log type as IISW3CLOG and hit F5. The result will be as shown below:

We can even write our own queries in SQL syntax to filter the data:
SELECT TOP 10 * FROM '[LOGFILEPATH]' where time-taken >100

As well, there are a few sets of built-in queries for IIS in the Library tab as shown below:

By using the Log Parser Studio, we can analyse large log files to determine load and performance issues at the page or user level. We can use IIS logs as a first step to troubleshoot performance issues. This log helps us to determine any performance issues that exist or not. If any exist then which page is taking time to respond and so on. I will end this article, by mentioning tools helpful in troubleshooting IIS issues in scenarios like a crash, hang, high CPU or memory and so on (we will discuss the following tools in depth in future articles):

    IIS Logging
    IIS Advanced Logging
    FREB Tracing [Failed Request Tracing]
    Fiddler or IE Developer Tools
    Memory dumps collection ofw3wp.exe using Debug Diag or AD Plus.
    Memory dumps analysis using WinDbg tool.

I hope this article will be helpful for all.

IIS Hosting Europe - HostForLIFE :: Create Virtual Directory In IIS

clock January 20, 2023 07:05 by author Peter

In this post I’m going to tell how to create a virtual directory in IIS. Most of the ASP.NET beginners wonder about how to create a virtual directory in IIS. In order to help them, I prepared this post. Before you proceed just check you have installed IIS on your local machine. If not, please check my previous post here,

What is Virtual Directory?
Virtual directory is a mapping between the actual web application files and IIS. That is we map the website files to the IIS in Virtual Directory. If you see in IIS, it looks like a directory but it actually points the exact web application path.

Create Virtual Directory
Here I’m going to create a virtual directory in IIS for the web application which is located in the path:  “G:\DotNetExamples\AllInOne”,

Step 1: Open IIS. To open IIS, press windows key + R key, which opens “Run” window and type “inetmgr” and press enter, which opens the IIS.

Step 2: In IIS, right click on the “Default Web Site” and select the “Add Application” in the float menu.

Step 3: In this “Add Application” window, we need to specify the “Virtual Directory” name and the physical directory where the actual web site files are located. Leave the application pool as it is. Click OK.

Step 4: Now the Virtual Directory has been created under the “Default Web Site”. To test the application right click the virtual directory and choose “Manage Application, then Browse” which will open the application in the respective default browser.

Hope this helps beginners!

IIS Hosting Europe - HostForLIFE :: Deploying A Blazor Application On IIS

clock January 10, 2023 08:07 by author Peter

In this article, we will understand how to deploy an ASP.NET Core hosted Blazor application with the help of IIS 10 on a Windows 10 machine. We will use Visual Studio 2017 to publish the app and SQL Server 2014 to handle DB operations. We will also troubleshoot some of the common hosting issues for a Blazor application.

Install IIS in your machine
Install URL Rewrite module from here

Please refer to my previous article Cascading DropDownList in Blazor Using EF Core to create the application that we will be deploying in this tutorial.

Installing .NET Core hosting bundle

Since we are going to deploy an ASP.NET Core hosted Blazor application, the first step is to install the .NET Core hosting bundle in our machine.
Follow the below steps to download .NET Core hosting bundle,

Step 1 
Open https://www.microsoft.com/net/download/all

Step 2 
Select the latest non-preview .NET Core runtime from the list. For this tutorial, we will select the .NET Core Runtime 2.0.7.

Refer to the image below, 

Step 3

On the .NET Core runtime download page, scroll down to the Windows section, select the “Hosting Bundle Installer” link to download the .NET Core Hosting Bundle. Once the download is finished, double-click to start installing it. You will see a window similar to the one shown below,

Important Note
  1. .NET Core hosting bundle should be installed after installing IIS only. If you install.NET Core hosting bundle before installing IIS then you need to repair it after installing IIS so that it will update its dependencies for IIS.
  2. Restart the machine after installing the .NET Core hosting bundle.
Publishing the Blazor application
Once .NET Core hosting bundle installation is successful and you have restarted your machine, open the Blazor application solution using VS 2017.

Right-click on the Server project of your solution and click publish. In this case, it will be BlazorDDL.Server >> Publish.

You will see a screen similar to below. Select the folder from the left menu and provide a folder path. You can provide any folder path where you want to publish your app.

Click on publish. Visual Studio will start publishing your application. If there are no build errors, then your application will be published successfully in the folder you have mentioned. After the publishing is successful, we will move on to configure IIS.

Configuring IIS
Open IIS and right-click on Sites >> Add Web Site.
An “Add Website” pop up box will open. Here we need to furnish details in three fields
  1. Site name: Put any name of your choice. Here I put "ankitsite"
  2. Physical Path: The path to the folder where you have published your application.
  3. Host name: This is the name we put in the browser to access our application. We will put ankitsite.com for this demo.
Click on OK to create the website. Refer to the image below:

Next step is to configure the “Application Pool” for our site. The application pool name will be the same as the “Site name” we have provided in the last step. Therefore, in this case, the application pool name will be “ankitsite”. Click to “Application Pools” from the left panel and double click on the pool “ankitsite”. It will open an “edit application pool” window. Select “No Managed Code” from the .NET CLR version drop-down. Refer to the image below:

Configuring the DNS host
The last step is to configure our DNS host file.

Navigate to C:\Windows\System32\drivers\etc path in your machine and open the “hosts” file using any text editor.

We need to add the hostname that we provided in IIS against the localhost IP address. Refer to the image below,

Hence, we have successfully hosted a Blazor application on IIS.
Execution Demo
 Open any browser on your machine and enter the hostname you have configured. You can see that the application will open in the browser window.

Troubleshooting common hosting issues
In this section, we will look into some of the common problems that you can face while hosting a Blazor application.
  • If you are unable to open the website and get a DNS not found an error
Check if the hostname is configured correctly in the host file. Make sure that your machine is not connected to any VPN server. Also, if you are using any Web proxy then disable it.
  • HTTP Error 500.19 – Internal Server Error - The requested page cannot be accessed because the related configuration data for the page is invalid. 
This error message is clear. The publish folder is inaccessible because of insufficient permissions. Grant Read permission to the IIS_IUSRS group on the publish folder so that it can access Web.config file.
  • If the website is loading but data is not getting populated and you get a 500 Internal server error 
Make sure that your connection string is in the correct format. The user id that you have specified in your connection string should have db_datareader and db_datawriter permissions. If the issue persists then provide the user with db_owner permission
  • If the data is not getting populated and you get an “operation not allowed” exception 
This issue generally appears when you try to do a PUT, POST or DELETE operation in your web API. To mitigate this issue we need to alter the IIS setup configuration.
Navigate to Control Panel >> Turn Windows feature on or off. Then navigate to Internet Information Services >> World Wide Web Services >> Common HTTP Features and uncheck the “WebDAV Publishing” option and click ok. Refer to the image below,

  • “Failed to load <web API> : No 'Access-Control-Allow-Origin' header is present on the requested resource.
The cause of this error is that the client and the server of the application are not on the same port. The browser will restrict the application to make web API calls due to same-origin policy. To resolve this issue you need to enable Cross-Origin Requests (CORS) in your application. 
  • If you republish the application then do not forget to refresh your website as well as the application pool in IIS. 


In this article, we learned how to deploy a Blazor application on IIS in windows machine. We also learned how to resolve some of the common hosting issues while deploying a Blazor application.

IIS Hosting Europe - HostForLIFE :: WebApi Hosting in Internet Information Server (IIS 7.5)

clock December 23, 2022 07:46 by author Peter

The Web API is a platform to develop HTTP / HTTPS based services that can be used by native applications like on smartphones, tablets and browsers. The WebApi is a core part of ASP.NET and provides ways to create Restful services and can be used by any application that can understand HTTP communications.

This article will cover the hosting of a WebApi in IIS using a sample demo. I hope you have gone through with the link above and now you at least understand the execution of WebApi. In this article we'll host the WebApi in IIS and execute all the CRUD operations step-by-step.

Step 1
Build your solution in release mode.

To build the solution, kindly download the sample application from the link Restful CRUD Operations in WebApi Using ADO.NET Objects and SQL Server and start working further. Please choose the release option from the dropdown list as encircled in red.

Step 2
Right-click on the project and choose the publish command to publish the Web API. Kindly look at the images shown below.

As soon as you click on the publish button it publishes the build and prompts for a message in the bottom of success as shown in the image below:

Step 3
Now type "Inetmgr” in the Start window and click on inetmgr to open IIS as shown in the image below:

Step 4
To add a new application as a virtual directory right-click on the default website and click on the Add application property. Please refer to the following image.

Provide an alias name of your choice and provide the physical path from your directory.

    It should be a published solution path that we've created in Step 2 above.
    Change the application pool “DefaultAppPool” to ASP.Net v4.0 after clicking on the “select” option. If you encounter an error like “unrecognized attribute 'targetframework'. Note that attribute names are case-sensitive IIS7” then here is the solution for that.

Step 5
The sample application has been hosted in IIS

The preceding Blue screen shows that the Web API is up and running. I've used Fiddler to trace the requests, so I will open Fiddler to execute the following link to retrieve the information of the EmployeeId 15: http://localhost/hfl/api/Employees/GetEmployeeById/15


Execution of AddEmployee (POST) Method of WebApi
Since the WebApi is already in running mode, I'll execute the following link to add an employee to the database. http://localhost/hfl/api/Employees/AddEmployee and will pass the following JSON parameters { "EmployeeId": 30, "Name" : "Peter", "ManagerId" : 7 }.


Please open the database to confirm whether or not the user has been added to the database. We are nearly done with the execution of the Post method.

Execution of DeleteEmployeeById (Delete) Method of WebApi.
Now open the EmployeeController again and paste the following code into that as the Delete WebApi method:

Since the WebApi is already in running mode, I'll execute the following link to delete an employee by the employee id database. http://localhost/DotnetPiper/api/Employees/Delete/20.

Note: If you face an error at time of execution of DELETE and PUT.Kindly refer this link for resolution.

WepApi HTTP Error 405.0 - Method Not Allowed

Please open the database to confirm that EmployeeId “20” has been deleted. Kindly look at the image shown below.

Note: I have intentionally left the implementation of the Update method so that the end user can have hands-on to this. I'll also add a database backup for user help.

Go through with these detailed links to learn more about the WebApi.
    How MediaTypeFormatter and MediaTypeMapping are associated with each other in the WebApi.
    WebAPI: MediaTypeFrommatters in WebAPI.

Detailed links to learn more about the WebApi.

Points to consider:
    You should have a little knowledge of the WebApi.
    You should have knowledge of the Fiddler tool to execute the functionality.
    There is a need for SQL Server also.

I hope it will help you somewhere down the line.
Keep coding and smiling.

IIS Hosting Europe - HostForLIFE :: netTcpBinding In WCF Service With IIS Hosting

clock December 16, 2022 06:50 by author Peter

Today, we will learn about creating the WCF Service using netTcpBinding and hosting it on IIS Server. If you are new to WCF, then please read my previous article (Create Simple WCF Service And Host It On Console Application).

Now, let's make simple WCF Service which gives the sum of two numbers.

Start the Visual Studio with administrator rights and create one class library project named as 'WCFAddition'.

This will generate default class file automatically. So, we have to delete it and add one new item as 'WCF Service' with the same name, 'WCFAddition'. This will generate one class file and one interface (WCFAddition.cs and IWCFAddition.cs).

Open the interface file and create method 'SumOfTwoNumber'.

    public interface IWCFAddition { 
        void DoWork(); 
        int SumOfTwoNumber(int num1, int num2); 

Now, implement this interface on class file.
    public class WCFAddition: IWCFAddition { 
        public void DoWork() {} 
        public int SumOfTwoNumber(int num1, int num2) { 
            return num1 + num2; 

Now, let's build the project solution and then add new web site in same solution for IIS hosting.

Give reference of WCF Service to this new website, as shown below.

Now, open Service.svc file and modify it as below.
    <%@ ServiceHost Language="C#" Debug="true" Service="WCFAddition.WCFAddition"%>   

The main part will start now and we have to make changes in web.config file. So here, first we have defined endpoint with netTcpBinding and then defined the base address for the same, as show below.
        <service name="WCFAddition.WCFAddition"> 
            <endpoint binding="netTcpBinding" bindingConfiguration="ultra" contract="WCFAddition.IWCFAddition" /> 
                    <add baseAddress="net.tcp://localhost:5050/implementclass" /> 
                    <add baseAddress="http://localhost:5051/implementclass" /> </baseAddresses> 

Define the behavior for the netTcpBinding.
                <serviceMetadata httpGetEnabled="true" /> 
                <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> 

Define binding as netTcpBinding with its default parameter properties. Also, define the security mode.
            <binding name="ultra" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="false" transactionFlow="false" listenBacklog="2147483647"> 
                <security mode="None"> 
                    <message clientCredentialType="None" /> 
                    <transport protectionLevel="None" clientCredentialType="None" /> </security> 
                <reliableSession enabled="false" /> </binding> 

Full web.config
    <?xml version="1.0"?> 
            <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> </appSettings> 
            <compilation debug="false" targetFramework="4.5.1" /> 
            <httpRuntime targetFramework="4.5.1" /> </system.web> 
                <service name="WCFAddition.WCFAddition"> 
                    <endpoint binding="netTcpBinding" bindingConfiguration="ultra" contract="WCFAddition.IWCFAddition" /> 
                            <add baseAddress="net.tcp://localhost:5050/implementclass" /> 
                            <add baseAddress="http://localhost:5051/implementclass" /> </baseAddresses> 
                    <binding name="ultra" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="false" transactionFlow="false" listenBacklog="2147483647"> 
                        <security mode="None"> 
                            <message clientCredentialType="None" /> 
                            <transport protectionLevel="None" clientCredentialType="None" /> </security> 
                        <reliableSession enabled="false" /> </binding> 
                        <serviceMetadata httpGetEnabled="true" /> 
                        <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> 
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> 
            <modules runAllManagedModulesForAllRequests="true" /> 

To browse web app root directory during debugging, set the value below to true.     
Set to false before deployment to avoid disclosing web app folder information. 
            <directoryBrowse enabled="true" /> </system.webServer> 

Now, when we have built the solution, we have to host it on IIS. So, open the IIS type 'inetmgr' command on run window.

It will open IIS. Go to ‘Sites’ and add new website

New window is open now. Give it a name as 'WCF_Addition' and assign physical path of your IIS project.

Now, in 'binding' section, select Type as http and add port '5051'. Click on OK button.


Now, select your web site and click on ‘Advance settings', as shown in the below image.

In 'Behavior' => 'Enable Protocols' = http,net .tcp and click on OK.

Now, click on 'Binding' link >> 'Add' button >> and add "net.tcp" and "505:*"

Our service is hosted now. Let's check it.

You can see that the service is hosted successfully on IIS and you can browse it on given URL.


IIS Hosting Europe - HostForLIFE :: IP Address and Domain Restrictions in IIS 8

clock December 2, 2022 06:32 by author Peter

This article covers how to configure Dynamic IP Restrictions.

IP Address and Domain Restrictions is one of the great built-in features of IIS 8. Configuring this feature allows a website administrator to selectively permit or deny access to the web server, websites, folders or files that makes your server more secure. One can configure and set the limits based on specific IP address(es) or frequency of requests from a specific IP over a period of time. By default all the clients requesting the website are permitted all access unless specifically rejected.

This feature was available in previous versions of IIS where you can block one IP or range of IP addresses. The disadvantage in this was first you need to know the person doing suspicious activity on your website based on the tools like Log Parser for checking the site logs then you can just block that IP or range of IP addresses using Deny Rules. Most of professional attackers (hackers) will use a variety of IPs from proxy servers so by the time you've blocked a handful a new range could be starting up.

Installing IP Address and Domain Restrictions in IIS 8

This feature is not installed by default. One must install the feature from the Turn Windows features On and Off window.

For that use the following procedure:

  1. Open the Control Panel.
  2. Click on the Programs feature.
  3. In that Click on Turn Windows features on or off under Programs and Features.
  4. Install the required features.

Configuring IP address and Domain Restrictions in IIS Manager
Open the IIS Manager. (Click WIN+R, enter inetmgr in the dialog and click OK. Alternatively, search for IIS Manger in the Start window).
Click on the IP Address and Domain Restrictions feature in the feature pane under the IIS section.

Once you opened this feature, you will see a window as in the following image.

The Action Pane elements are the elements used for defining the rules for allowing or denying the specific IP address(es). Let's have a deeper look into each of these elements.
Edit Feature Settings
This action is used for specifying the default access to all unspecified clients in Add and Deny rules.
On clicking this action, it will open up a window as in the following image.

Select Allow in the Access for unspecified clients dropdown if you are to allow all clients by default else select Deny.

If you want to configure rules based on the client's DNS name then check the Enable Domain Name Restrictions checkbox. If you click on OK to save the settings when this checkbox was checked then it will show a warning (as in the following image) that states that doing DNS lookups is a potentially expensive operation. Click on Yes to enable DNS lookup restrictions.

If you want to enable the requests that come through a proxy server then check Enable Proxy Mode checkbox.
Choose the Default Deny Action Type for sending the response to clients when you are denied a request. It can be either Unauthorized (401), Forbidden (403), Not Found (404) or Abort the request.
Once you have selected your options click on OK to save the settings.

Add Allow/ Deny Entry
These two action types are used for defining the rule for allowing or blocking the specific IP address or range of IP addresses.
On clicking the action, it will open one window as provided in the following image.

To create a rule for a specific IP Address, select Specific IP Address and enter the client IP address in the provided TextBox.
To create a rule for a range of IP addresses, select IP address range and enter the subnet and subnet mask in the provided textboxes. For example, to permit access to all IP addresses in the range from to then enter the subnet as and subnet mask as the

If you have enabled Domain Name Restrictions in the feature settings, then you will be able to set restrictions based on DNS names else this option will not be available. To create a rule for a client domain name, then select Domain name and enter the DNS name.

After entering the details click on OK to add the rule.

Edit Dynamic Restriction Settings
This is the new feature that came with IIS 8.
On configuring this feature one can secure their web applications from automated attacks like Dictionary attacks.
This action allows to dynamically determine whether to block certain clients, based on number of concurrent requests at a time or number of requests over a period of time.
On clicking this action, it will open a window as provided in the following image.

If you want to restrict the client based on a number of concurrent requests, then check the Deny IP Address based on number of concurrent requests check boxand enter Maximum number of concurrent requests count in the provided TextBox.

If you want to restrict the client based on number of requests over a period of time, then check the provided checkbox and enter the details in the provided textboxes.

Check the Enable the Logging Only Mode checkbox if you want IIS to log requests that would be rejected.

View Ordered List
This action is used for changing the rule priority.
On clicking this action, you will be able to see the screen that is showing rules places in the order and with multiple action elements as provided in the following image.

Rules located at the top of the list have higher priority.
Use Move Up and Move Down actions to change the priority of the rules.
Once you are done with changing the order of the rules then click on View Unordered List to return to the screen that allows you to add and remove rules.


This action is used to remove the rules that are not required.
To view this action click on any of the rules in the feature pane and then click on Remove to remove the rule.
On clicking Remove, you will get a warning as in the following image. Click on Yes to remove the rule.

Feature pane elements that give the information about the rules are applicable to the current web site or virtual application.
      This displays the type of rule. It contains the values, either Allow or Deny, that indicates whether the created rule is to allow or deny access to content.

      This displays the specific IP address or range of IP addresses or domain name defined in the Add Allow/Deny Restriction Rule.

    Entry Type
      This displays whether the item is local or inherited. Local items are added in the current application level and inherited items are added from a parent application level.

About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.

Tag cloud

Sign in