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 :: Handle 404 Error React Router On Refresh Windows Server

clock January 17, 2024 07:01 by author Peter

Have you ever seen a blank screen or 404 error when trying to reload a page in a React Router-powered application? This happens when there are no defined routes in the application's routing setup that match the URL path.


Note: I've been having trouble with this and have since figured out a solution, so this is only for Windows server hosting.

This is happening as a result of the Single Page Application (SPA) that your website is built on React. Your application, index.html, loads automatically when you access the website through the root directory. and hence you never truly leave the index.html page even when you navigate to other pages.

Make sure the URL Rewrite module is enabled in your server setup. You can change or rewrite the URLs with this module.

  • Go to Control Panel -> Programs -> Programs and Features.
  • Click on "Turn Windows features on or off" on the left sidebar.
  • Scroll down and locate "Internet Information Services," expand it, and then select "World Wide Web Services" -> "Common HTTP Features" -> "URL Rewrite."
  • Click "OK" and let the feature be installed.

Once the URL Rewrite module is enabled, open your project's web.config file (located in the root directory of your application).

<system.webserver>
<rewrite>
  <rules>
    <rule name="React Router" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="/" />
    </rule>
  </rules>
</rewrite>
</system.webserver>

Note: Before using the aforementioned technique, make sure your React application is developed and deployed correctly on the Windows server.



IIS Hosting Europe - HostForLIFE :: IIS 10 - Step By Step Guide to create a Self-Signed Certificate

clock December 8, 2023 06:34 by author Peter

I'll walk you through the process of making a self-signed certificate using IIS version 10 in this article.

Describe SSL
The Secure Socket Layer is the Full Form of SSL.

We can protect your customers' data from online thieves using SSL protocol on your website. For instance, an SSL certificate is necessary to secure client data on e-commerce or banking websites that store credit card information.

I hope you now have a basic grasp. Let's use IIS 10 to build a self-signed certificate.
Construct a Self-Signed Certification

Please use IIS to create a self-signed certificate by following the instructions below.

Create a Self-Signed Certificate
Please follow the below steps to create a Self-Signed Certificate using IIS.

Step 1. Go to the Start menu and click on Administrative Tools -> Internet Information Services (IIS) Manager.

Or

Click “inetmgr” in the search bar to open IIS.

2. Select the Internet Information Service (IIS) Manager by clicking on it. Choose the "Server Certificates" option by clicking the name of the server.

Step 3: Press the Server Certificate button. From the menu on the right, choose "Create Self-Signed Certificate."

"Create Self-Signed certification" should be clicked.

Step 4: Name the folder and provide a "Friendly Name" for the certificate's storage.

I selected the “Personal” folder and clicked on the Ok button. A self-Signed certificate will be created.

I'll walk you through attaching this certificate to your website so that it is HTTPS in the future article. I hope you find this material interesting and useful. I appreciate your time.



IIS Hosting Europe - HostForLIFE :: Publishing ASP.NET Core 8 on IIS

clock November 28, 2023 07:20 by author Peter

How do I make ASP.NET Core 8 available on IIS (Internet Information Service)?
This tutorial assumes you already have a pool set up on your Windows Server IIS.


Follow the steps to grasp the methods for publishing ASP.NET Core 8 applications on IIS settings.

You must configure your code to support IIS and the project to run on the target pool's architecture.

Check the inetmgr console, the Advanced setting..., and make sure Enable 32-Bit programs is set to true to see if your pool is running on x86.

Let's get started on the publishing process.

Step 1: Launch your new ASP.NET Core MVC application.

Step 3. I tried to publish and got an error 503. It's normal, this is what we will fix.


Step 4. So I added this code to Program.cs to enable IIS Server options.
builder.Services.Configure<IISServerOptions>(options =>
{
    options.AutomaticAuthentication = false;
});

Step 5. Open the solution configuration, and choose New... from Active solution platform.

Step 6. Choose your architecture pool. It should be the same as the pool on IIS (x86 for 32-Bits).


Step 7. It will look like this.

Step 8. Back to Publish configuration, you need to change for this.

Step 9. But you will get the same error if you try to publish.

Step 10. To fix this, you need to configure your application to run under Windows, adding <TargetFramework>net8.0-windows</TargetFramework>, unload the project and edit it.
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <Platforms>AnyCPU;x86</Platforms>
  </PropertyGroup>

</Project>


Step 11. Now, if you open the Properties of your application, you will see that it is enabled to Target OS version 7.0.


Step 12. Now, you need to select the Target Framework: with "net8.0-windows":


Step 13. Before publishing a dotnet, copy the file app_offline.htm to the target IIS installation folder. This turns off the website so this message is displayed if you try to use it:


Step 13.1. Extra source code, Microsoft default source code. If the file name app_offline.htm indicates to dotnet that the execution should be terminated, it automatically redirects to it. You can customize this file as you like.
<!doctype html>
<title>Site Maintenance</title>
<style>
  body { text-align: center; padding: 150px; }
  h1 { font-size: 50px; }
  body { font: 20px Helvetica, sans-serif; color: #333; }
  article { display: block; text-align: left; width: 650px; margin: 0 auto; }
  a { color: #dc8100; text-decoration: none; }
  a:hover { color: #333; text-decoration: none; }
</style>

<article>
    <h1>We&rsquo;ll be back soon!</h1>
    <div>
        <p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. we&rsquo;ll be back online shortly!</p>
    </div>
</article>

Step 14. Copy the files, then delete the app_offline.htm file to run the application. This is the result.

Conclusion
There are a few steps, but it is essential to follow them to succeed in publishing ASP.NET Core 8 applications.



IIS Hosting Europe - HostForLIFE :: IIS Server is Used to Host and Publish .NET Core 6 Web API Applications

clock November 8, 2023 09:25 by author Peter

Internet Information Service (IIS) is essentially Microsoft's versatile and general-purpose web server that will run on Windows and be used to serve requested files.

Required Tools

  • IIS Manager
  • .NET Core SDK 6
  • Visual Studio 2022


Let’s start
Step 1. Create a new .NET Core Web API Project.

Step 2: Set up your new project.

Step 3: Include details such as the.NET Framework version, Open API, and HTTPS.

Step 4. Project Structure

Step 5: Create the Product Controller and add one endpoint within that class, as well as inspect the other files that are generated by default.

using Microsoft.AspNetCore.Mvc;
namespace WebAPI.Controllers {
    [Route("api/[controller]")]
    [ApiController]
    public class ProductsController: ControllerBase {
        [HttpGet]
        [Route("list")]
        public IDictionary < int, string > Get() {
            IDictionary < int, string > list = new Dictionary < int, string > ();
            list.Add(1, "IPhone");
            list.Add(2, "Laptop");
            list.Add(3, "Samsung TV");
            return list;
        }
    }
}

Program.cs file

var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment() || app.Environment.IsProduction()) {
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();


Here also, you can see we configure the HTTP request pipeline for both Development and Production Environment.

WebAPI.csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
  </ItemGroup>
</Project>


launchSetting.json file
{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:11254",
      "sslPort": 44315
    }
  },
  "profiles": {
    "WebAPI": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:7047;http://localhost:5047",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}


Step 6. Run your application and hit the API endpoint using Swagger UI

Step 7. Check your all IIS Services are running on your system properly or not. If not, then open the control panel go to the program and features, and click on Turn Windows Feature on or off.

 

Apply the changes as I showed you in the above image. Click on apply and then restart your computer

Step 8. After restarting your computer will see IIS Manager in the search box and open it.

Now, check your running IIS using localhost in the browser

Step 9. Install ASP.NET Core 6.9 Runtime – Windows Hosting Bundle Installer

    Windows hosting bundle installer

Step 10. Now, we are going to publish our application for that; right-click on WebAPI Project and click on Publish


As you see, it will take the default path, so change that path to c:\inetpub\wwwroot\publish after creating the publish folder over there

Step 11. Here you can see all the configurations related to publishing, like path and some environmental variables, and later on, click on Publish

Step 12. Open IIS Manager and create a new Web Application after right click on the sites

Step 13. Click on Web API, and on the right side, you can see the browse option, so click on that and open the application inside the browser


Step 14. In the browser, when you hit the Web API endpoint using Swagger, then will see the following list of products as an output

Conclusion
In this article, we discussed.NET Core 6 Web API hosting and publishing using IIS, as well as associated topics step by step. I hope you comprehend everything.



IIS Hosting Europe - HostForLIFE :: Deploy An Angular Application On IIS

clock June 16, 2023 08:55 by author Peter

This article will help every developer who works on Angular. In this article, we are going to see the steps necessary to deploy an Angular application on Internet Information Services (IIS).

What is covered in this article    How to Install IIS.    Create and build an Angular application.    Deploy Angular application on IIS. How to Install IIS
To install IIS, press the Windows + R key combination to bring up a run box. Then, type appwiz.cpl and press Enter.

Now, open the "Program and Features" part of the Control Panel, on the left-hand side, click on the "Turn Windows features on or off" link.

Now, click on the "Internet Information Services" checkbox.

Step 1
Let us create a project using the following command in Command Prompt.
 
ng new IISDemo

Step 2
Open the project in Visual Studio Code using the following command.
cd IISDemo

Step 3
Build the application by using the following command.
ng build --prod --base-href /eapp/

A folder is created in your project folder with a name list. Open C drive, create a new folder named IISDemo, and paste the dist folder content.
Deploy Angular Application on IIS
 
Now, open IIS, press the Windows + R key combination to bring up a run box. Then, type inetmgr and press Enter.
 
Now, IIS will start.

Now, right-click on Sites and click on "Add web sites".


Now, right-click on Demo and click on "Add Application". Fill the alias name and set the physical path.

Now, enable Directory Browsing.
Now, browse to your Angular application.
Right-click on the app, go to Manage Application and click on "Browse".


 

In this article, I have discussed how to deploy an Angular Application on IIS.



IIS Hosting Europe - HostForLIFE :: How To Host Web-App In IIS 10.0?

clock May 16, 2023 07:45 by author Peter

Listed below are the steps to deploy a web app in IIS.


Step 1
Publish your application.
Right click your application and select "Publish".

In the publishing wizard, select the desired file system and set target location.

And now, click Publish button to publish your application to the targeted location. Once the application is published successfully, the following screen appears (if any errors occurs, it will notify  you here).

Step 2
Type inetmgr in the "Run" dialog box to open IIS manager.


And, you will get to the below screen.

Expand the local computer, right click on Sites, and click "Add New Site", as shown below.

Type the name of the website. In my sample, it is "MyWebApp". Select the published file location (you have to manually add this port number to inbound rules of Windows Firewall later). And then, press OK.

If a connection with that port number already exists, then give another port number.

So, change the port number and press OK.
Browse to view the application.

It's hosted on localhost.

If you want to assign IP-address, right click your created site in IIS and select "Edit Binding".

In "Site Bindings" window, click "Edit" and assign IP address.

Now, click OK and type this IP address with port in browser (ex: http://192.168.1.113:91/ ). You will see the following screen.


Now, you can see that our application is hosted with IP Address on IIS successfully.



IIS Hosting Europe - HostForLIFE :: How To Change Localhost To Custom Domain Name In IIS?

clock April 12, 2023 09:11 by author Peter

Most developers face a lot of problems while releasing a website in the production/hosting environment because they don't have experience with local IIS and custom domain names. IIS Express (localhost) provides developers with almost all the settings for development and debugging. Since most of the developers work with IIS Express, they have a lot of issues while working on the real server (hosting environment).


Instead of running, developing, and debugging (testing) a website using a localhost URL (like http://localhost:), local IIS (custom domain name) gives a good feel and looks professional. Setting a custom domain name instead of localhost will help you during website development, debugging, and its release.

Often, developers release security patches and updates to their customers. For this, they require the versioning of the domain. The virtual directory and application concept in IIS (Internet Information Services) helps developers to a version that I will also discuss in my article.

In this tutorial, I am going to explain various steps to change localhost to a custom domain name in IIS.

Terminologies

As per Wikipedia, "Internet Information Services (IIS, formerly Internet Information Server) is an extensible web server software created by Microsoft for use with the Windows NT family. IIS supports HTTP, HTTP/2, HTTPS, FTP, FTPS, SMTP and NNTP".
Application Pool

An application pool defines a group of one or more worker processes, configured with common settings that serve requests to one or more applications that are assigned to that application pool. Since application pools allow a set of web apps to share one or more similarly configured worker processes, they provide an easy way to isolate a group of web applications from other web applications on the server machine.

With the help of application pools, we can achieve the level of application isolation required in terms of availability and security by deploying applications across multiple application pools. Each worker process is separated by process boundaries. Therefore, problems with applications in one application pool have no effect on sites or applications in other application pools. Application pools significantly increase the dependability and management of your web infrastructure.

Site
A site is a container for applications and virtual directories that can be accessed through one or more unique bindings. Binding has two major communication properties:
    Binding Protocol: It defines the protocol over which communication between the server and the client occurs. It can be either HTTP or HTTPS.
    Binding Information: It defines the information that is used to access the site. It is the combination of IP address, port, and optional host header.

If a site requires different protocols or binding information, it may have more than one binding.

Note
In earlier versions of IIS, only the HTTP and HTTPS protocols were supported, but in IIS 7 and above, bindings can apply to any protocol.

Application
An application is a set of files that delivers content or provides services over a protocol, such as HTTP. When you create an application in IIS, the path to the application becomes part of the URL of the site.

Virtual Directory
A virtual directory is a directory name (also called a path) that you specify in IIS and mapped to a physical/virtual directory on the system.

Note
Virtual Directories aren't supported with ASP.NET Core apps. An ASP.NET Core app can be hosted as an IIS sub-application.

In short, a site can contain more than one application or virtual directory, an application can contain more than one application or virtual directory, and a virtual directory can contain more than one application.

Prerequisites
    IIS (Internet Information Services)
    Running Project (Here, I am using an ASP.NET web application).
    Web Browser (Whatever you use, but I like Microsoft Edge)

IIS (Internet Information Services) Setup Configurations
This section will tell you how to set up IIS (Internet Information Services) in your system. First of all, we have to check whether our system has IIS enabled or not? For this open any of your favorite browsers and just type the following URL, "IIS Windows".

If you get this page, it means that you have already enabled IIS in your system. So, you can skip this section and go to the next section.

If you get this error, it means you need to enable it. So, stay with us and follow the steps given below very carefully. (Make sure you are connected to the Internet when configuring it).

Note
You can also check if you have IIS enabled on your system by searching for "IIS" in your Universal Search, which is next to the Start button.

Step 1
Click Start and type "Turn Windows features on or off" in the search bar. Then, click Turn Windows features on or off to open Windows Features.

Step 2
Search for "Internet Information Services" and check it and every box that appears in it needs to be checked. Click on the "OK" button to proceed.

Make sure you have checked every box inside it. Because if some features are left, it will cause problems in IIS while mapping your application.

Step 3
After successful installation, a message will appear on the screen "Windows completed the requested changes". Now, click Close. (Now, you have to restart your system to apply all the changes).


After the system restarts, search for IIS again in your Universal Search Bar near the Start button. You will see the IIS as a result. Now, click on, to open it. (Alternatively, you can confirm it by typing the following URL, IIS Windows in any of your favorite browsers).

Congratulations, you have successfully enabled IIS in your system.
Changing Localhost to Custom Domain Name Configurations

Step 1
Click Start and type "IIS". Then click "Internet Information Services (IIS) Manager" to open the Internet Information Services (IIS) Manager.

Step 2
First, we create a new application pool to host our new application. Follow steps 2a and 2b very carefully to create a new application pool.

Step 2a
Right-click on the Application Pools, and click on "Add Application Pool...".

Step 2b
Now, create a new application pool by choosing the following configurations. (Note, if you are using the latest version of the .NET framework, select the following options).

    Give a name to your new application pool
    Select ".NET CLR Version v4.0.30319" option from .NET CLR Version
    Select the "Integrated" option from Managed pipeline mode

Step 3
Right-click on the Sites and select the "Add Website..." option from the list.

Step 4
Now, enter the details as per the given fields and your requirements. And, click the "OK" button.

Site Name: Choose a name for your new website.
Application pool: Select the "Application pool" that you have created earlier, by clicking on the "Select" option.
Physical path: Select the main (root) directory of the application.
Host name: Now, it's time to set up your custom domain name. In the "Host name" field, type the custom domain name you want for your application.

Note
If you do not select the Application Pool, a new application pool is created using the name of the site when the site is added. IIS defaults to one application pool per site.

Step 5
It's time to register/map your custom domain name with your local IP (127.0.0.1). To do this, navigate to the following path, "C:\Windows\System32\drivers\etc" and open the "hosts" file in any text editor with the Administrator privileges. Remember that, you will need administrator privileges to save your changes in the "hosts" file.

This is a sample HOSTS file used by Microsoft TCP/IP for Windows. This file contains the mappings of IP addresses to host names. Each entry should be kept on an individual line. The IP address should be placed in the first column followed by the corresponding host name. The IP address and the host name should be separated by at least one space. Additionally, comments may be inserted on individual lines or following the machine name denoted by a '#' symbol.

For example:

    102.54.94.97     rhino.acme.com      # source server
    38.25.63.10       x.acme.com           # x client host

Now, map your custom domain name as in the following example and save the file.

Congratulations, you have successfully changed localhost to the custom domain name for your application.



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

clock March 15, 2023 08:14 by author Peter

Introduction
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 
    { 
        [ServiceContract] 
        public interface IProducts 
        { 
            [OperationContract] 
            string GetProductName(); 
     
            [OperationContract] 
             string GetProductQty(); 
     
            [OperationContract] 
             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" ?> 
    <configuration> 
     
      <system.web> 
        <compilation debug="true" /> 
      </system.web> 
      <!-- 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. --> 
      <system.serviceModel> 
        <services> 
          <service name="CarService.ProductService"> 
            <endpoint address="" binding="wsHttpBinding" contract="CarService.IProduct"> 
              <identity> 
                <dns value="localhost" /> 
              </identity> 
            </endpoint> 
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
            <host> 
              <baseAddresses> 
                <add           baseAddress="http://localhost:8732/Design_Time_Addresses/CarService/Service1/"/> 
              </baseAddresses> 
            </host> 
          </service> 
        </services> 
        <behaviors> 
          <serviceBehaviors> 
            <behavior> 
              <!-- 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" /> 
            </behavior> 
          </serviceBehaviors> 
        </behaviors> 
      </system.serviceModel> 
     
    </configuration>


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.



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