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 8.0 Hosting UK - HostForLIFE.eu :: Error Message 401.2: Unauthorized - Logon Failed Due To Server Configuration

clock March 7, 2024 06:40 by author Peter

Sometimes we receive this error message after publishing the solution in IIS. This mistake is very common.

Exact Error
Error message 401.2: Unauthorized The login failed due to server configuration. Check that you have authorization to browse this directory or page using the credentials you provided and the authentication methods enabled on the Web server. For further assistance, contact the web server administrator.

This problem is mostly caused by IIS's authentication settings.

Launch the IIS.

Choose the site where you are experiencing the problem.
Select Authentication. Setting as indicated.

Authentication choices can be updated based on your application's requirements.

In my case, the application needs to set windows authentication, therefore, I set it to enabled and Anonymous Authentication Disabled.

IIS 8.0 Hosting UK - HostForLIFE.eu :: Protect Static Files In ASP.NET Web Forms With The Help Of HTTP Handle

clock February 27, 2024 08:03 by author Peter

First, let me explain the problem I encountered in the web forms application (ASPX). I have a legacy web application that was created in ASP.NET and deployed on IIS 10. Static files (PDF, JS, CSS, JSON, and all forms of pictures (jpg, png, BMP, etc.)) are stored in a subfolder on the site called data, such as http://example.com/data/...When an unauthenticated person browses the files.


http://example.com/data/image.gif or http://example.com/data/sample.css or http://example.com/data/sample.js).
It will display the files without authentication. In other words, the pages should only be accessible once the user is authorized.

IIS Default Behavior By default, the IIS web server routes ASP.NET resource requests to the ASP.NET runtime, but it handles static content requests directly. As a result, requests for static content are served without consideration for the URL authorization requirements specified in the ASP.NET application settings.

When I try to browse this issues regarding the same in internet , there are lot of things like enabling runAllManagedModulesForAllRequests="true" but nothings works out. Even though I am running my application in integrated mode in IIS.

Then I came to know about HTTPHandler. Below is the definition of HTTP Handler from Microsoft.

HTTP modules and HTTP handlers are an integral part of the ASP.NET architecture. While a request is being processed, each request is processed by multiple HTTP modules (for example, the authentication module and the session module) and is then processed by a single HTTP handler. After the handler has processed the request, the request flows back through the HTTP modules.

HTTPHandlers are used by ASP.NET web application server to handle specific requests based on extensions. HTTPHandlers run as processes in response to a request made to the ASP.NET website. It is a class that implements the System.
How to implement HTTPHandler to handle any incoming HTTP request with a path like .gif/.js/.css?

  • Create a class file — it could be FileProtectionHandler.cs
  • Let FileProtectionHandler class inherit from IhttpHandler Interface.
  • In FileProtectionHandler class, implement all the methods which are found in IhttpHandler Interface.

When a request comes, it will check whether it will be authenticated or not, if not it will redirect to login page otherwise will send the requested file based on the file extension.
using System;
using System.IO;
using System.Web;
namespace Example.UI {
    public class FileProtectionHandler: IHttpHandler {
        /// <summary>
        /// You will need to configure this handler in the Web.config file of your
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: https://go.microsoft.com/?linkid=8101007
        /// </summary>
        #region IHttpHandler Members
        public bool IsReusable {
            // Return false in case your Managed Handler cannot be reused for another request.
            // Usually this would be false in case you have some state information preserved per request.
            get {
                return true;
        public void ProcessRequest(HttpContext context) {
            //write your handler implementation here.
            if (!context.User.Identity.IsAuthenticated) {
            } else {
                string requestedFile = context.Server.MapPath(context.Request.FilePath);
                SendContentTypeAndFile(context, requestedFile);
        private HttpContext SendContentTypeAndFile(HttpContext context, string strFile) {
            context.Response.ContentType = GetContentType(strFile);
            return context;
        private string GetContentType(string fileName) {
            string res = null;
            FileInfo fileInfo = new FileInfo(fileName);
            if (fileInfo.Exists) {
                switch (fileInfo.Extension.Remove(0, 1).ToLower()) {
                    case "pdf": {
                        res = "application/pdf";
                    case "gif": {
                        res = "image/gif";
            return res;

The next step is to register the HTTP handler in the Web.config file. Based on your IIS version, it should be added as a child of <system.web> or <system.webServer>. Refer here to register
    <add path="*.gif" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.png" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.jpg" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.js" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.svg" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.bmp" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.json" verb="*" type="MyProject.FileProtectionHandler" validate="false" />
    <add path="*.css" verb="*" type="MyProject.FileProtectionHandler" validate="false" />

That’s all. Now HTTP Handler is ready
Once this configuration information has been specified in Web.config revisit the image file hosted via IIS from your browser. This time while processing the request for the image file IIS allows for the ASP.NET runtime to perform authentication and authorization logic. The ASP.NET runtime notes that the request is coming from an anonymous user and is for a URL that denies anonymous users. Therefore, the anonymous user is redirected to the login page, just like when visiting the image file served by the ASP.NET Development Server.

IIS 8.0 Hosting UK - HostForLIFE.eu :: Recognizing and Handling.Net Server-Side (Output) Caching

clock January 29, 2024 07:41 by author Peter

A user's request does not go to the database every time they visit a website in order to answer every detail. As an alternative, some data is extracted directly, which speeds up and improves efficiency. This tactic enables the server to process numerous requests from various users without interfering with the database. Important information is stored in the server's memory so that it can respond to your request promptly.

Given that data is typically saved in databases, you may be asking how the server obtains, stores, and locates this data.

Thus, the Internet Information Services, or IIS, serves as the operation's beating heart.

Output Caching is the name of the operation.

Even the type of file and duration of storage are customizable. by using the easy steps listed below.

  • On your server, open the Internet Information Services (IIS) Manager.
  • Access your web application by navigating through the Connections pane.
  • Give the "Output Caching" feature a double-click.
  • Examine the cached items, their expiration dates, and other pertinent details in the "Output Caching" feature.

But how can the cache be kept there?
Installing System is hence the first step.Net.Caching from the Nuget bundle

Caching in System.Web
You can implement caching within a server-side web application, usually hosted by Internet Information Services (IIS), by using the classes provided by the System.Web.Caching namespace. The caching method uses the server's RAM to cache data when you use the System.Web.Caching namespace in an ASP.NET web application hosted on Internet Information Services (IIS).

HttpRuntime.Cache.Insert("yourkey","your value");To do CRUD activities with such caches, there are a few methods under this namespace.

This is how the cache is set. You might have noticed, though, that the code above doesn't indicate when this caching item expires. This suggests that unless the web application is terminated or restarted, the caching item won't be destroyed. As a result, you must also include an expiration.

Here's another method to get there:

     string key,
     object value,
     System.Web.Caching.CacheDependency dependencies,
     DateTime absoluteExpiration,
     TimeSpan slidingExpiration

You are aware of the value and key in this case, but what about the other parameters?

Dependencies: When any of a cache item's dependencies are altered or eliminated, the cache item will be automatically cleared.

Nonetheless, if you would like it to stay in the cache until further specified expiration conditions (such absolute or sliding expiration) are satisfied or until it is manually deleted.

Absolute Expiration: The cache can have a precise expiration time that you specify. To set its value, there are three options:

  • Absolute Time of Expiration: AbsoluteTime belongs to the DateTime type. You designate a precise day and time for the cache item to expire. The cache expires when this date and time are reached.
  • Save.NoAbsoluteExpiration: This constant value means that the item will stay in the cache until it is manually removed, and it does not have an absolute expiration period.
  • Blending using Adaptive Expiration:  The slidingExpiration parameter needs to be set to NoSlidingExpiration if you are utilizing absolute expiration.

Declining Expiration
1. Sliding Expiration makes sure that the cache item lifespan will be increased by the interval value if the data is accessed within the designated time frame. For instance, a session with a 10-minute expiration is introduced.
TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(30), NoSlidingExpiration, etc. are few examples.

2. Combining with AbsoluteExpiration: NoAbsoluteExpiration is required as the absolute expiration argument if sliding expiration is being used.

IIS 8.0 Hosting UK - HostForLIFE.eu :: IIS Website Debugging Using Visual Studio

clock January 15, 2024 06:43 by author Peter

Start Visual Studio: Open the Visual Studio project or solution that is associated with your IIS website.

Configure IIS: Verify that your IIS website is set up and operational. If not, set it up by making a fresh website or utilizing an already-existing one.
Build Configuration: Verify that the configuration for your project contains debugging details. Usually, the "Debug" setting would be utilized.
Begin debugging: Click on the "Start Debugging" button in Visual Studio (or press `F5`). This will connect the debugger and start your application.
Attach to Process: To attach the debugger to an already-running IIS website, go to the "Debug" menu, pick "Attach to Process," and select the process that corresponds to your IIS application pool (in most cases, `w3wp.exe} for IIS worker processes).
Choose the Appropriate Code: Verify that the source code you wish to debug is the same one that IIS is using. Make sure the right project and build configuration are chosen by checking the configuration of the solution.
Establish Breakpoints: Whenever you want the debugger to pause so you may walk through the code and examine variables, place breakpoints in your code.
Debugging: You can now debug your IIS website once it has been attached. At the breakpoints, Visual Studio will pause, allowing you to step through code, examine variables, and troubleshoot problems with the debugging tools.

Keep in mind that in order to attach the debugger to the IIS process and adjust the IIS application pool settings appropriately, you should have the required permissions for efficient debugging.

You should be able to connect the Visual Studio debugger to your IIS website in order to debug it by following these instructions.

Windows Server Hosting - HostForLIFE :: How to Install the File Server Resource Manager (FSRM)

clock December 5, 2023 08:01 by author Peter

In this post, I'll walk you through the process of installing the file server resource manager correctly and quickly.

Prior to proceeding, let us clarify what file server resource manager is. It is a Windows Server role service that helps you organize and manage data kept on file servers. You can use FSRM to automatically classify files, perform tasks based on these classifications, set quotas on folders, and create reports monitoring storage usage.

The File Server Resource Manager (FSRM) should be installed first. In your sever dashboard click "add roles and features".

Step 4. Click "next".

Step 5. Click the "file and storage" arrow mark and again click the "file and iSCSI" arrow mark. After that, select "file server resource manager".

Step 6. Once you click "file server resource manager" you will see the message in this step click "add features".

Step 7. Click "next".

Step 8. Click "next".

Step 9. Click the "restart" option, and then you will get the warring message. After that click "yes" and then click "install".

Step 10. After that, you can see the installed wizard.

In this article, we all clearly understand how to install the file server resource manager in a proper method. If there is clarification regarding this topic, feel free to contact me.

IIS 8.0 Hosting UK - HostForLIFE.eu :: How To Remove IIS On Windows Server 2012

clock November 17, 2023 08:07 by author Peter

Today's article will teach you how to uninstall Internet Information Services 8 (IIS8) from Windows Server 2012.

Step 1
To begin, enter your password into your Windows Server 2012 as Administrator. If your Server Manager does not launch automatically after logging in, open it by clicking the first button in the task bar.

When you launch the Server Manager, the following window will appear:

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 is complete, your Windows Server 2012 will be restarted because you already granted permission to do so.

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 8 Hosting - HostForLIFE :: Programmatically Create IIS Website and Application Pool Using C#

clock November 16, 2023 09:25 by author Peter

In this post, we will look at how to use a C# console application to create an IIS website and accompanying application pool programmatically. These tasks are typically performed by an IIS administrator.

We can use this application to automate those tasks. In Visual Studio 2010, construct a console application named IISAutomation and target.NET 3.5, as seen below.

Add a reference to Microsoft.Web.Administration, which may be found at C:WindowsSystem32inetsrv [IIS installation directory]. This assembly contains classes that can be used by a developer to administer the IIS Manager. First, we'll build an application pool with the code below:

private static void CreateAppPool(string pool name,bool enable32bitOn64, ManagedPipelineMode mode,string runtimeVersion="v4.0")
    using (ServerManager serverManager = new ServerManager())
        ApplicationPool newPool = serverManager.ApplicationPools.Add(poolname);
        newPool.ManagedRuntimeVersion = runtimeVersion;
        newPool.Enable32BitAppOnWin64 = true;
        newPool.ManagedPipelineMode = mode;

Here, we created an application pool by creating an instance of the application pool object. Then, we set the properties of the application pool, like the name, the .NET version to be used, and the committed changes by calling CommitChanges(). Similarly, we will create a website using the following code:
private static void CreateIISWebsite(string website name, string hostname, string phyPath, string app pool)
    ServerManager iisManager = new ServerManager();
    iisManager.Sites.Add(websiteName, "http", "*:80:" + hostname, phyPath);
    iisManager.Sites[websiteName].ApplicationDefaults.ApplicationPoolName = appPool;

    foreach (var item in iisManager.Sites[websiteName].Applications)
        item.ApplicationPoolName = appPool;


Here, we created a new website by creating an instance of ServerManager, adding it to the Sites collection setting its properties like name, physical path, and so on and committed the changes.

We will use the preceding methods in our Main method and create an application pool and a website using the following code:

static void Main(string[] args)
    Console.WriteLine("Do you want to create an Application Pool:y/n");
    string response = Console.ReadLine();
    if (response.ToString() == "y")
        Console.Write("Please enter Application Pool Name:");
        string poolname = Console.ReadLine();
        bool isEnable32bit = false;
        ManagedPipelineMode mode = ManagedPipelineMode.Classic;
        Console.Write("Need to enable 32 bit on Windows 64 bit?y/n [Applicable for 64 bit OS]: y/n?");
        string enable32bit = Console.ReadLine();
        if (enable32bit.ToLower() == "y")
            isEnable32bit = true;
        Console.Write("Please select Pipeline Mode: 1 for Classic, 2 for Integrated:");
        string pipelinemode = Console.ReadLine();
        if (pipelinemode.ToLower() == "2")
            mode = ManagedPipelineMode.Integrated;
        Console.Write("Please select Runtime Version for Application Pool: 1 for v2.0, 2 for v4.0:");
        string runtimeVersion = Console.ReadLine()== "1" ? "v2.0" : "v4.0";

        CreateAppPool(poolname, isEnable32bit, mode, runtimeVersion);
        Console.WriteLine("Application Pool created successfully...");
                Console.WriteLine("Do you want to create a website:y/n");
    response = Console.ReadLine();
    if (response.ToString() == "y")
        Console.Write("Please enter website name:");
        string websiteName = Console.ReadLine();
        Console.Write("Please enter host name:");
        string hostname = Console.ReadLine();
        Console.Write("Please enter physical path to point for website:");
        string phypath = Console.ReadLine();
        Console.WriteLine("Please enter Application pool Name:");
        foreach(var pool in new ServerManager().ApplicationPools)
        Console.Write("Please enter Application pool Name for web site:");
        string poolName = Console.ReadLine();
        Console.WriteLine("Web site created successfully...");

Here, we set the attributes necessary for website and application creation by getting input from the console. Let's run the application and input the details as shown below:

We can develop websites and application pools more quickly and easily using this program. I'm wrapping things up here. I've attached the source code for your convenience. I hope everyone finds this article useful.

IIS 8 Hosting - HostForLIFE :: How Do I Deploy and Publish a.NET 7 Application in IIS?

clock August 22, 2023 12:50 by author Peter

This article walks you through the process of installing and publishing a.NET 7 application to Internet Information Services (IIS).

Step 1: Configure IIS (Optional)
If IIS is not already configured, we can use the procedures below to enable it.
Navigate to the Control Panel > Programs > Programs and Features > Turn on or off Windows features.
Increase the availability of Internet Information Services, World Wide Web Services, and Application Development Tools.

Step 2: On the IIS server, install the.NET Core Hosting Bundle.
Check that your server has IIS installed and configured correctly. Otherwise, you can proceed with the optional procedures listed above.
Ascertain that the required components for hosting.NET 7 applications are enabled. The hosting package includes the.NET Core Runtime,.NET Core Library, and the ASP.NET Core Module.

After installation, please restart the server.

Step 3: Save to a File Folder
Right-click the project you wish to deploy in Visual Studio and select publish.

Click on Folder > Next > Folder location will populate the default path as “bin\Release\net7.0\publish\”. > Click on Finish > Publish.

OPTIONAL - An alternative method for generating published files,
Navigate to the root directory of your.NET 7 project in a terminal.
To publish your application, use the following command:
dotnet publish -c Release -o PublishOutput

This will compile your application in Release mode and generate the necessary files in the Publish folder.

Step 4. Copy Files to Preferred IIS Location
Now, copy the published files to the location where they should be stored. In our case, let's copy the files to C:\inetpub\wwwroot\EmpoyeeAPI.

Step 5: In IIS, create an application and configure the application pool.
On your server, launch the IIS Manager.
To host your application, either create a new site or use an existing one. Select "Add Website" from the context menu when you right-click on the "Sites" node.
Provide a site name, a physical path (to the previous step's PublishOutput folder), and an optional hostname.

Because.NET 7 uses the.NET Core runtime, make sure the.NET CLR version is set to "No Managed Code."
Select Application Pools > Choose the name of the application pool > Configure the.NET CLR version to "No Managed Code" > Select "Integrated" as the pipeline mode.

Step 6. Test your app after deployment
After configuring the site, try accessing it through a web browser. Make sure everything is working as expected.

Important note: Because we are delivering Web API in our situation, the Swagger UI middleware is often retained within the app.Environment.Check the IsDevelopment() function. I kept this swagger middleware outside of this condition for demonstration purposes so that we could test the page in a browser.

IIS 8 Hosting - HostForLIFE :: ASP.NET Core Application Remote Debugging on a Remote IIS

clock July 26, 2023 08:45 by author Peter

You may have experienced the situation where your ASP.NET Core application runs smoothly while developed on your PC and in Visual Studio, but encounters issues and fails to produce the desired results when published on IIS. In this circumstance, remote debugging is precisely what can be helpful.

How does Remote Debugger function?
You can debug input requests to IIS through Visual Studio by using a remote debugger, which is positioned between IIS and Visual Studio and transmits queries from IIS to Visual Studio.

Before configuring Remote Debugger, please note the following considerations:

  • Remote Debugger is not available if the IIS machine and Visual Studio machine are connected through a proxy.
  • If the connection between the IIS machine and the Visual Studio machine has high latency or low bandwidth, then using Remote Debugger is not recommended.


  • Install Remote Debugger on IIS machine
  • Check that the required ports are open in the firewall (by default, Port 4026 fot for Visual Studio 2022 or Port 4024 for Visual Studio 2019 and optionally UDP Port 3702 for discovery)
  • The application should be deployed to IIS using Debug configuration
  • The application deployed to IIS and the source code in Visual Studio should be exactly the same. Otherwise, the breakpoints in Visual Studio will not be hit.

How to Configure Remote Debugger?
1. Install Remote Debugger on the IIS machine. To install Remote Debugger, you can follow one of these two options:
If you have Visual Studio installed, then you can copy Remote Debugger from the Visual Studio installation path to the IIS machine. Remote Debugger usually is located in the following path: C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Remote Debugger. If you have installed Visual Studio on other locations than the C:\Program Files, then you need to change the path respectively. Also, if you have installed Visual Studio other than the 2022 or Preview version, then the path should change respectively too.
Download the Remote Debugger and install it on an IIS machine.
You can download the Remote Debugger from the following url: Download Remote Debugger

2. Suppose that we have followed the first option so in order to start the Remote Debugger on the IIS machine, double click on msvsmon.exe to run the Remote Debugger. After running the msvsmon.exe following window will be opened:

As it is shown in the following image, Remote Debugger is up and waiting for new connections through port number 4026. In the following image, VAHID-LEGION is the name of the IIS server. Now that we have Remote Debugger up and run. Next, we need to go to the Visual Studio and try to connect to Remote Debugger.

3. In Visual Studio, go to Debug>Attach to Process

4. In Connection target, enter the IIS machine address as specified in msvsmon.exe and click on find.

3. Remote Connections window will be opened. In this window, select the IIS Machine and the click on Select button.

5. Wait until the connection is established and the process list is populated. From the process list, find the process associated with your website/web application in IIS. To easily find the process, you can enter w3wp in the search box to filter the process list. After finding the process on the IIS machine, select it and click on Attach.

6. If the Attach Security Warning window is shown, just click on Attach if you are sure to attach to the process.

7. Now, your website/web application on an IIS machine and your Visual Studio are connected to each other. You can now put a breakpoint in Visual Studio and start sending requests to IIS, to see that while processing the request, your breakpoints in Visual Studio are being hit.

Congratulation! you have successfully set up the Remote Debugger. But before you proceed, please note that you should not use this approach on production servers. because as you saw, breakpoints cause your application to be completely halted, and this can harm your application performance and usability. Just use this approach and similar approaches in test or staging environments.

IIS 8 Hosting - HostForLIFE :: ASP.NET MVC Application Deployment on IIS Server

clock June 20, 2023 08:22 by author Peter

Microsoft's Internet Information Services (IIS) is a flexible, general-purpose web server that delivers HTML pages or files requested on Windows computers.

Client workstations located remotely can submit queries to an IIS web server, which will then return the appropriate response. Using this foundational functionality, Web servers can share and distribute data across LANs, such as corporate intranets, and WANs, such as the Internet.

A web server can provide users with information in numerous formats, including HTML-coded static web pages, file downloads and uploads, text documents, and image files.
ASP.Net MVC Application Deployment on IIS Server

Step 1
Using Visual Studio, develop the ASP.net MVC application.

Select the Project Type as MVC and hit the create button.

Now our Project is in the initial Deployment stage.

Now our application is ready for Deployment on IIS Server.

Step 2
Now right click on the application and hit the publish option.

Step 3
Select the deployment options.

We will select the Folder option.

Create the Directory in your system for Application Build.

Select your folder for application build.

Hit the Finish button and we are good to go.

Our application build was created successfully.

Our Deployment Build is ready.

Step 4
Open the IIS Server.

Right click on the websites and add a new website. Give the name of the website and add the physical path for your application where you stored the application build. The next step will be to give the Hostname to your website (Simply the Domain Name)

Deploying Asp.net MVC Application on IIS Server

You can see the setting in the below screenshot.

Now click the OK button.

Step 5
Open the C Drive and find the system 32 Folder. Open the Driver Folder and after that, open the etc. folder and then open the Host File


Open the Host file using Notepad.

Now open CMD and find your IP Address.
Set the IP Address and Host name in Host file in the way I am doing below.


Now go to IIS Server and browse your website.

Now our application is live on IIS Server.


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