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 :: 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'.

    [ServiceContract] 
    public interface IWCFAddition { 
        [OperationContract] 
        void DoWork(); 
        [OperationContract] 
        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.
    <services> 
        <service name="WCFAddition.WCFAddition"> 
            <endpoint binding="netTcpBinding" bindingConfiguration="ultra" contract="WCFAddition.IWCFAddition" /> 
            <host> 
                <baseAddresses> 
                    <add baseAddress="net.tcp://localhost:5050/implementclass" /> 
                    <add baseAddress="http://localhost:5051/implementclass" /> </baseAddresses> 
            </host> 
        </service> 
    </services>  

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

Define binding as netTcpBinding with its default parameter properties. Also, define the security mode.
    <bindings> 
        <netTcpBinding> 
            <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> 
        </netTcpBinding> 
    </bindings>  

Full web.config
    <?xml version="1.0"?> 
    <configuration> 
        <appSettings> 
            <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> </appSettings> 
        <system.web> 
            <compilation debug="false" targetFramework="4.5.1" /> 
            <httpRuntime targetFramework="4.5.1" /> </system.web> 
        <system.serviceModel> 
            <services> 
                <service name="WCFAddition.WCFAddition"> 
                    <endpoint binding="netTcpBinding" bindingConfiguration="ultra" contract="WCFAddition.IWCFAddition" /> 
                    <host> 
                        <baseAddresses> 
                            <add baseAddress="net.tcp://localhost:5050/implementclass" /> 
                            <add baseAddress="http://localhost:5051/implementclass" /> </baseAddresses> 
                    </host> 
                </service> 
            </services> 
            <bindings> 
                <netTcpBinding> 
                    <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> 
                </netTcpBinding> 
            </bindings> 
            <behaviors> 
                <serviceBehaviors> 
                    <behavior> 
                        <serviceMetadata httpGetEnabled="true" /> 
                        <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> 
                </serviceBehaviors> 
            </behaviors> 
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> 
        <system.webServer> 
            <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> 
    </configuration>  

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.

Introduction
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.


Background
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 192.168.8.0 to 192.168.8.8 then enter the subnet as 192.168.8.0 and subnet mask as the 255.0.0.0.

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.

Remove

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.
    Mode
      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.

    Requester
      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.



IIS Hosting Europe - HostForLIFE :: Look at HTTP API Logs in IIS 7

clock November 25, 2022 06:47 by author Peter

In this article, we will look into the HTTP API error log feature of IIS 7/ 7.5, when to use it and how to analyze it. When a connection times out, dropped or a request is orphaned on your website, it will be logged in the HTTP API error log file by IIS under "c:\Windows\System32\LogFiles\HTTPERR\httperr#.log". This file helps us to identify the following kinds of errors:


    Connection time-outs for a pending request.
    Orphaned requests when w3wp.exe crashes or stops unexpectedly, while there are pending queued requests.
    Error responses to clients like parser errors.

Let's look at the following sample HTTPERR#.LOG file:In this article, we will look into the HTTP API error log feature of IIS 7/ 7.5, when to use it and how to analyze it. When a connection times out, dropped or a request is orphaned on your website, it will be logged in the HTTP API error log file by IIS under "c:\Windows\System32\LogFiles\HTTPERR\httperr#.log". This file helps us to identify the following kinds of errors:

    Connection time-outs for a pending request.
    Orphaned requests when w3wp.exe crashes or stops unexpectedly, while there are pending queued requests.
    Error responses to clients like parser errors.

Let's look at the following sample HTTPERR#.LOG file:

It shows date, time, client's IP, port as well the s-reason field that shows specific error types, like BadRequest, Connection_Dropped and the following is the explanation for that field's value:

s-reason Description
AppOffline A service unavailable error occurred (an HTTP error 503). The service is not available because application errors caused the application to be taken offline.
AppPoolTimer A service unavailable error occurred (an HTTP error 503). The service is not available because the application pool process is too busy to handle the request.
AppShutdown A service unavailable error occurred (an HTTP error 503). The service is not available because the application shut down automatically in response to administrator policy.
BadRequest A parse error occurred while processing a request.
Client_Reset The connection between the client and the server was closed before the request could be assigned to a worker process. The most common cause of this behavior is that the client prematurely closes its connection to the server.

This field will help us to understand what exactly caused the problem like Application Pool is down or is it a Bad request or a connection timed out.

We can use the Log Parser to better analyze HTTPERR#.LOG files. Open the Log Parser and point to the log file as shown below:

Go to the library and filter it by httperr as shown below:


Let's find abandoned requests by selecting "HTTPERR: Abandoned Requests" and hitting F5 to execute the query:


Analyzing HTTPERR#.LOG with the Log parser will help us to identify connection time-outs, orphaned requests, bad requests and so on quickly.



IIS Hosting Europe - HostForLIFE :: Access Website Hosted In IIS On Windows 10 From Any PC On LAN

clock October 21, 2022 08:07 by author Peter

In this article, we will learn about Access Website Hosted In IIS On Windows 10 From Any PC On LAN


Prerequisites

    Windows 10 PC with IIS installed. (In this example IIS version is 10 )
    Basic knowledge of website hosting on IIS.

Create a website in IIS
 
Open run (windows key + R) and type inetmgr and press enter or in Cortana Search type IIS.

IIS Manager opens.
Then right click on Sites and click on Add Website. The Add website dialog opens.

    Fill in required details and select folder where compiled code is located. Eg: C:\Nigel\Publish
    Select required port , default is 80. I will be using 7500.
    Do not enter host name details if you are testing or using on LAN.

Then click ok. A website gets created and it will show under Sites.
 

Now right click on website name then Manage website and then click browse.


The link should be in the form on http://localhost:7500/  if you used port 7500 and selected http.
Locate your IP Address

Now open command prompt. Type cmd in run.


Type ipconfig and press enter. Now locate your PC's IP address on the LAN.


Now in your website link replace localhost with 192.168.0.24 (IP address) so your URL will be - http://192.168.0.24:7500/
Try it in your browser to make sure it works.
 
Change Firewall Rules
In Cortana search type firewall then click on Windows firewall with advanced security.


The firewall window opens.


Click on Inbound rules on the left. Then click new Rule in the right side menu.

The New inbound rule wizard will open. What type of rule would you like to create? Select Port and click Next.

In Does this rule apply to TCP or UDP? Select TCP. Then enter port number (7500) in specific local ports textbox. Then click Next >.

Then the Action form opens. Select Allow the connection and click Next .


Then the profile form opens. In the When does this rule apply? - Select required ones , if not sure then select all. Click Next.

Give this Firewall rule a Name and Description, so you know for what purpose you created this. Then click finish.


Now if you share the link we created earlier with someone else on your LAN it should open your website.
Link example: http://192.168.0.24:7500/
 
Note
    Be careful when changing Firewall setting otherwise you may leave your PC vulnerable to online attacks.
    Only use ports in non standard range (preferably after 9000).
    Once you are done using the website you can delete the Firewall rule.

Summary
In this article, we learned about Access Website Hosted In IIS On Windows 10 From Any PC On LAN.



IIS Hosting Europe - HostForLIFE :: Configure IIS to host your website without Asp.net

clock October 14, 2022 10:44 by author Peter

This article describes how to set up IIS on your PC then host your web site without

Visual Studio Installed.
If you want, in a Client's machine if you don't install Visual Studio but want to host your website in it then you can do this. It can be very usefull for you.

Step 1 : Install IIS on Your Server Machine
Go with this way .

Start -> Control Panel -> Add Remove Programs -> Add/Removes Windows Components.
Then click on Window Component Wizard Internet Information Service (IIS)

Click the Checkbox for Internet Information Service (IIS) then click the next button and select browse to XP Installation CD for Required Files.
 
Then install the .Net Framework.

Step 2 : Install .Net Framework on Your Server Machine.
After IIS installation, install the .Net Framework; which one depends on what you used to develop your web site.


Step 3: After Installation Set Your Web Site For hosting

After IIS installation, on the C drive the Inetpub folder is created.

Copy and paste your web site folder into the wwwroot folder.

Inetpub -> wwwroot -> yourwebsitefolder

Step 4: After pasting your folder is set on the default web site.

Right-click on My Computer then click the manage option.

Manage -> Computer management (Local) -> Internet Information Service -> Website -> Default Web Site.

On right-click default Web Site Click New -> Virtual Directory.

On Virtual Directory Creation Wizard click next then set Alias Name.
After write alias name click next and browse your directory on wwwroot folder website . . then set all Access Permission Checked.
Read...Write...Browse

After finishing check the .Net Framework version; on right-click for your web site properties on the ASP.NET tab. If the version is not selected then choose it ASP.Net Version and set it. Then browse to your web site.

And in the client machine that you want to run the web site in, give the URL with server IP address.

http://192.168.192.1/Onlineshoping/Index.aspx

Enjoy Your Web Project.

Conclusion:
I am try do something helpful.



IIS Hosting Europe - HostForLIFE :: How To Deploy React Application On IIS Server?

clock August 31, 2022 09:31 by author Peter

Today, I am going to show you how to deploy the React App to the IIS server, so let's grab a cup of coffee and start coding.

 
What is IIS?
IIS stands for "Internet Information Services", which is a web server provided by Microsoft to host the websites and other stuff on the web.
 
How to enable IIS?
If you have already enabled IIS then you can skip this step. But if you have not enabled it already then follow the below steps:
    Open Control Panel and then click on the "Programs and Features".
    Click on "Turn Windows features on or off".
    Select Internet Information Services and click on the OK button.
    To see whether or not IIS is enabled, press Windows + R key and type inetmgr and click on OK.
    IIS Manager is open.

Create a Simple React App
Open a command prompt or your favorite terminal and type the below command to create a react app.
    npx create-react-app my-react-app  

 After successfully creating the app go to the new app.
    cd my-react-app  

To see how it look likes type the below command.
    npm start  

and it will start the development server and navigate you to http://localhost:3000/
 
You can see the default landing page:

To host an app in any web server we first need to create a production build. To create a production build of our react app use the below command.

    npm run build  

The output of the above command creates a new build folder inside the project which contains production build. So far we have created a React app & created a production build of that app. Now the next step is to deploy it on IIS. Press Windows + R key and write inetmgr to open the IIS Manager. You can see the below screen.

 
First, we will create a new Application Pool, so right-click on Application Pools and click on Add Application Pool. Then give it a name as you want and click on OK button.
 
After that right-click on the new app pool and select Advanced Settings. You will see the below window.


Then click on Identity and choose a Custom account and click on the set button and then add your windows credentials and click on OK.
 
After that right-click on Sites and then click on Add Website. Add the Site name and select application pool which we created earlier. After that under the physical path section, you have to give the path of build folder & also give the port number where you want to host.

Now right click on new website i.e ReactApp -> Manage Website -> Browse. Your react app is now successfully deployed.


Now the next step is to add routing in our react application. So I have created 2 components and also added react-router-dom package for routing. Here we are not going into detail about react routing.
 
Home page

Blog page

 

Create a production build again and try to browse the application which we hosted on IIS. You will see the application is working fine but now try to refresh the page and see what happens. You will get the below error.

So to fix this issue you have to install URL Rewrite module. After successful installation, you have to create a web.config file under public folder of app and copy-paste the below content into it.
<?xml version="1.0"?>  
<configuration>  
<system.webServer>  
    <rewrite>  
        <rules>  
            <rule name="React Routes" stopProcessing="true">  
                <match url=".*" />  
                <conditions logicalGrouping="MatchAll">  
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />  
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />  
                    <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />  
                </conditions>  
                <action type="Rewrite" url="/" />  
            </rule>  
        </rules>  
    </rewrite>  
</system.webServer>  
</configuration>     


Again build the application in production mode and browse. So now if you refresh the app you will not get an error and will be able to see the correct page. That's it -- so you have successfully created and deployed React application into the IIS server.

Conclusion

I hope that you have enjoyed this article, and please do not hesitate to send me your thoughts or comments about what could I have done better.



IIS Hosting Europe - HostForLIFE :: Publish And Host ASP.NET Core Web API On IIS

clock August 16, 2022 08:46 by author Peter

In this article you are going to learn about how to publish and host an ASP .Net Core Web API project on IIS.

Tools
    Visual Studio
    .Net Core SDK (Any Compatible Version)
    IIS Manager

Continuing from my previous article I’m going to use my project which I created already. There are several ways to do this but we will discuss the simplest way to do this. Just follow the steps as defined below.
 
Steps
First download .Net Core SDK compatible with your API version, I’m using .NET Core 2.1 so I downloaded it from here.
After downloading the SDK, open it and install it on your PC.

After installation create a new folder in C:\inetpub\wwwroot directory with the name “publish” as shown in figure below.

Right click the project and select Publish.

Visual Studio gives a default path, you can publish your API there but I am using another way to do this. So, click on browse.

Select the folder (publish) you created before and click Open.


After this the target location for publish project files will be changed, then simply click Publish.


It will take some time to publish. After the files are published, Open IIS Manager.

Now open IIS Manager.

Expand your connection and right click on Sites folder to add Website.


Give the site name and the Select the application Pool to DeaultAppPool.

Give a physical path of your folder where you published the API project.


Give the Port number 8085 or any you want and then click OK.

Right click on your new added site and Manage Site and click Browse, it will automatically open your hosted website in the browser.


Now give the URL http://localhost:8085/Values/GetStatus, this is the actual path of your Controller action and after writing just press enter. You will see the following results.


You can test other actions also by giving their URL as in given example above.
 
Conclusion
This article provides a brief introduction of publishing .NET Core Web API project and hosting it on IIS. Hope you find it useful and helpful for your work or studies.



IIS Hosting Europe - HostForLIFE :: Hosting ASP.NET Web API REST Service On IIS 10

clock August 5, 2022 07:35 by author Peter

To make any application accessible to the end-user, we need to host it on a server. So, in this article, we will learn how to host ASP.NET Web API REST Service in IIS 10. The following steps are required to host any application.

Step 1 Install IIS
Before hosting any application, make sure that IIS (Internet Information Services) is installed on your Hosting Server. If it is not installed or enabled, then follow the below steps.
    Click on Windows icon at the bottom left corner and find the "Control Panel" menu and click on it.
    In the "Control Panel", find the "Program and Features" option from the displayed list.
    This shows the list of installed programs. Find and click the "Turn Windows feature on or off" option from the left pane, as shown in the following image.

    Now, in the next popup, find Internet Information Services (IIS) and check on it.
    Click "Next" button and then "Finish". It takes a few minutes to install IIS.
    After installing IIS, restart your machine.

Note - I have Windows 10 OS and the above process is for Windows 10 PC. The steps might differ depending on your Operating System version.
 
Step 2 Install .NET Framework
 
Although Visual Studio is not required on your hosting Server, it must have .NET Framework installed, as per the .NET framework used to develop the application. If it is not installed, then please install the appropriate .NET Framework available on Microsoft official website.
 
I assume, you have installed the .NET framework on your Hosting Server.
 
Step 3 Move the published code on Hosting Server
 
Copy the "Published files" and paste those on respective Servers where you want to host the Web API REST Service. In our last article, we published Web API REST Service in the E drive of my Server, as shown in the following image .
 

Step 4 Open IIS Manager
Now, open the IIS Manager from Windows menu or in any other ways you have known.


The above image is of IIS 10 Manager of my Windows 10 machine. The view as well as options might be different on your machine depending on the OS version.

Step 5 Add Website
Right click on "Site" in IIS and click on add new website, as shown in the following screenshot.
 

 

After clicking on "Add Website" option, it displays the following configuration window.


I hope you understood the preceding configuration by highlighted text.
 
Step 6 Define Site Name & Application Pool
Define the site name which will be useful to uniquely identify the site within the IIS Server. After specifying the site name, choose the Application Pool from available pools. You can even create a custom application pool with any desired name. Currently, our IIS Manager has the following Application Pools.


Choose the application pool depending on your application configuration. In this article, we are going to choose DefaultAppPool.

Step 7 Browse and select Published Folder path
Now, choose the physical location of published code files by clicking on "Browse" button, as shown in the following image.


Now, click on "OK" button.
 
Step 8 Define IP address & Port
 
Choose one IP address from the list of available IP addresses and define the unique port number for the application, which will be unique within the defined IP address.

Step 9 Choose Protocol & Host name (optional )
 
Choose the protocol for your application i.e HTTP or HTTPS which requires port 443 to be open and choose the Host name which will be used publicly to access the application. After defining all the configurations, the web site configuration window will look like this.


Now, click on OK button. It will create and add the application in IIS.


Step 10 Browse the URL with REST Client
 
Browse the hosted application using REST client with base URL along with API, Controller name, and Action method name, with pattern defined in routing template inside the webapiconfig.cs file.
 
We can browse applications using the browser but then, we can only test the GET method. So, to test all types of Action Methods, we are using  advanced REST client which is a developer extension tool in Firefox browser.
 
Our hosted Web API REST Service includes these two methods, as given below.

    GetAllEmployees (GET )
    GetEmployeeById  (POST ) which takes id as input parameter

Browse GetAllEmployees method using Advanced REST client which has used HTTP GET verb.

The GetAllEmployees hosted Web API REST method is returning all the employee lists.
 
Now, browse GetEmployeeById method using Advanced REST client which uses HTTP POST verb and takes id as input parameter.


From the above desired output, it's clear that our Web API REST Service is hosted on IIS successfully.

Note
    Download the Zip file of the Published code to learn and start quickly.
    This article is just guideline to show how to host Web API REST Service on IIS .
    Optimize the speed by setting debug as false etc., from web.config file as per your skills.
    In this article, the optimization is not covered in depth.
    Configure the authentication in IIS as per your REST Service .

Summary

I hope, this article is useful for all readers. If you have any suggestions, please mention them in the comments section.



IIS Hosting Europe - HostForLIFE :: Host And Publish .NET Core 6 Web API Application On IIS Server

clock July 4, 2022 09:35 by author Peter

We are going to discuss how to host and publish .NET Core 6 Web API on IIS Server


Basically, Internet Information Service (IIS) is the flexible and general-purpose web server provided by Microsoft that will be run on Windows and 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
Configure your new project


Step 3
Provide additional information like .NET Framework Version, Open API, and HTTPS


Step 4
Project Structure


Step 5
Create the Product Controller and add one endpoint inside that class and also check other files which are created 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 use 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 and 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 and 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

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 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


In this article, we discussed .NET Core 6 Web API hosting and publish related things using IIS and things related to that step-by-step. I hope you understand all things.
Happy Coding!



IIS Hosting Europe - HostForLIFE :: Deploy ASP.NET Core API application In IIS

clock March 29, 2022 09:04 by author Peter

ASP.NET Core is a cross platform and open source framework which is used to build  modern web apps, API services and many more. In this article we are going to see how to deploy the ASP.NET Core API application in IIS.

 
Tooling

    Visual Studio 2019
    IIS
    POSTMAN

Creating an application
 
Open Visual Studio 2019 -> Click on create new project from the start up screen.

Click on ASP.NET Core Web application template -> give the project name, in my case I named it as AspCoreHosting -> click on create.
Choose API template, as shown in below figure.

Now run the application from visual studio and test the API in POSTMAN as shown in the below figure.

Deploy the application to IIS
Let’s create a package of the application, right click on the project and select publish, as shown in the below figure.


Choose IIS, FTP, etc option from publish target list and choose the publish method as file system, and click on save.

Open IIS, right click on application pools -> Add app pool -> Choose the .NET CLR Version as No Manager Code and name the app pool. in my case I named it as .NET Core V2.2 with pipeline mode as Integrated.


Note
Creating a new application pool for .NET Core is optional
 
Right click on sites -> Add site ->Give the Site name -> select the Application pool as .NET Core V2.2 -> choose the package path -> and give a port number as shown in the below figure.


Run the web site



Oops we got a configuration error. The problem is, to run the .NET Core application in IIS we need to install “dot net core windows hosting bundle”. Just download and install it using the below link.

 

Once it is installed, test the API using POSTMAN tool


Yes, now the application is up and running in IIS
We have seen how to deploy the ASP.NET Core API application in IIS by installing the dot net core windows hosting bundle.



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