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 :: Remove IIS Log Files

clock October 14, 2024 09:04 by author Peter

The log files that IIS generates can, over time, consume a large amount of disk space. This article will discuss a way to remove the IIS Log Files, including locate the log file directory. The content of this article is


Introduction

  • Problem
  • How to locate the IIS Log File Folder
  • Run the VB Scrip

Problem:
IIS log files continue to grow in Web Server and can, over time, consume a large amount of disk space. Logs can potentially fill up an entire hard drive. To mitigate this problem, many users turn off logging completely. Fortunately, there are alternatives to doing so, such as the following:

  • Enable folder compression
  • Move the log folder to a remote system
  • Delete old log files by script.

Here we will discuss the third option.

How to locate the IIS Log File Folder

By default, the IIS log file folder is in %SystemDrive%\inetpub\logs\LogFiles, it is usually in C:\inetpub\logs\LogFiles. However, the location can be customized by user. We have two ways to locate the IIS Log Folder

  • through IIS Manager
  • through Running a Script, such as Windows PowerShell Script

Through IIS Manager:
Open IIS Manager => Click the Chosen  Site under Sites => Double Click the Logging Icon

 

In the Logging page, the IIS Log File Folder is shown in the Direcitory:
such as %SystemDrive%\inetpub\logs\LogFiles by default

In certain case, it is set by user,
such as D:\LOGS\IIS\

Through Windows PowerShell Script:
Import-Module WebAdministration

# Replace 'Default Web Site' with the name of your website
$siteName = 'Default Web Site'

# Get the log file directory
$logFilePath = Get-ItemProperty "IIS:\Sites\$siteName" -Name logFile | Select-Object -ExpandProperty Directory

Write-Output "The log files for '$siteName' are located at: $logFilePath"


If we put the code in a PowerShell Script file: GotLogFolder1.ps1, we got the default folder:

In a customized case, the folder could be different:

For the IIS structure:

Run VB Script to Remove the IIS log files by Retention Policy

Microsoft provide a VB Script to implement this:
You can control disk usage of log files by running a script that automatically deletes log files that are older than a certain age. Running this script in a scheduled task will keep the problem of a disk filling up under control without constant maintenance.

The following VBScript will check the age of each log file in a folder and will delete any log file older than a specified age. To customize the script for your purposes, simply change the name and path of the folder in line 1 of the script, and change the maximum age to the desired value in days, in line 2.
sLogFolder = "c:\inetpub\logs\LogFiles"
iMaxAge = 30   'in days
Set objFSO = CreateObject("Scripting.FileSystemObject")
set colFolder = objFSO.GetFolder(sLogFolder)
For Each colSubfolder in colFolder.SubFolders
        Set objFolder = objFSO.GetFolder(colSubfolder.Path)
        Set colFiles = objFolder.Files
        For Each objFile in colFiles
                iFileAge = now-objFile.DateCreated
                if iFileAge > (iMaxAge+1)  then
                        objFSO.deletefile objFile, True
                end if
        Next
Next


How to run the VB Script?
Windows Script Host enables you to run scripts from Windows ether by WScript or CScript, you still run the scripts in the same manner. The difference is only in the output — WScript generates windowed output, while CScript sends its output to the command window in which it was started.



IIS Hosting Europe - HostForLIFE :: How to Fix Windows Services Stopping at Startup and How to Resolve?

clock October 10, 2024 09:08 by author Peter

Imagine this: A critical Windows service that you just launched is meant to maintain the seamless operation of your organization. However, the moment you launch it, the service abruptly ends after 30 seconds, leaving you furious and scratching your head. Users are experiencing problems that are becoming worse by the minute, and the logs aren't offering definitive explanations. What isn't working well?

Stopped services
This is a scenario that many developers and IT professionals encounter when working with Windows services. The core of this problem is a specific behavior enforced by the Service Control Manager (SCM), which expects the OnStart method of your service to complete within a strict 30-second window. If your service doesn’t comply, the SCM will assume a failure and halt the service.

In this article, we’ll dive deep into the reasons why your Windows service might be stopping right after it starts and explore the mechanics behind the SCM’s behavior. Whether you’re troubleshooting an existing service or designing a new one, understanding this common factor will help you create more resilient and reliable services.

To resolve this issue, consider the following approaches.

  • Optimize Initialization Code: Review and refactor the code in the OnStart method to ensure it executes as quickly as possible. If certain operations are time-consuming, consider moving them to a separate thread or background worker. Make sure executing the Onstart method does not take more than 30 seconds.
  • Increase the Timeout: This approach is not recommended as a first step. It’s possible to extend the startup timeout by modifying the service’s properties in the registry. However, this should be done with caution, as it may lead to other performance issues.

Follow the below steps to increase service time out.

  • Press Win + R, type regedit, and press Enter. This opens the Windows Registry Editor.
  • In the Registry Editor, navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control.
  • Right-click on the Control key, select New, then DWORD (32-bit) Value.

Regedit

  • Name this new value “ServicesPipeTimeout”.
  • Double-click the “ServicesPipeTimeout” value you just created.

ServicesPipeTimeout

  • In the “Value data” field, enter the desired timeout value in milliseconds. In this case, we will be setting a timeout of 60 seconds, so we will input “60000” as value data and ensure that the base is set to Decimal.
  • For the changes to take effect, restart your system.

Important note

  • Modifying the registry can have unintended side effects if not done correctly. Always back up the registry before making any changes.
  • The “ServicesPipeTimeout” value affects all services on the system, not just the specific service you're troubleshooting.
  • While increasing the timeout can prevent premature service stoppages, it can also delay the detection of legitimate service startup failures.

Conclusion
While increasing the timeout via the registry is an option, it’s often more recommended and also effective to optimize your OnStart method or use asynchronous tasks.
By doing so, you can prevent premature service stoppages and ensure your service runs smoothly and efficiently.



IIS Hosting Europe - HostForLIFE :: Log Parser Usage Details For IIS Logs

clock August 23, 2024 07:47 by author Peter

We can parse various log kinds with the aid of Log Parser Studio. The primary topic of this lesson will be IIS log parsing. There are two Log Parser programs: one that can only be used with a command prompt and the other that includes full GUI support.

Installation

Below is the sample query for Log Parser with GUI to get the output from IIS logs for a URL and other data like [MAX, MIN, AVG] – Response Time in mili seconds and hits.
SELECT cs-uri-stem as URL,
MAX(time-taken) As Max,
MIN(time-taken) As Min,
Avg(time-taken) As Average,
Count(1) as Hits
FROM '[LOGFILEPATH]'
GROUP BY URL
ORDER BY Average DESC


Below is the sample query to run in Log Parser with the command prompt version.
Logparser -i: iisw3c “ SELECT cs-uri-stem as URL,
MAX(time-taken) As Max,
MIN(time-taken) As Min,
Avg(time-taken) As Average,
Count(1) as Hits from D:\test.log GROUP By URL ORDER BY Average DESC TO D:\result.csv” –o : csv


Usage details Log parser studio
The landing screen of Log Parser Studio is given below.

As we are interested in parsing IIS logs, so select IIS-Top25 slow URLs.

The query with all the details will be shown to the user.

Now, we need to choose the IIS logs file. Click the Choose log files icon.

The dialog box with the options will be shown, where we have to select the individual log files or the folder. Now, we need to click the icon to execute an active query.

Below is the screenshot of Log Parser Studio with the results. The data for Max, Min, and Average refers to Response Time in mili seconds. We can copy data or export the data, as required.



IIS Hosting Europe - HostForLIFE :: Install Windows 10 and Configure IIS

clock July 10, 2024 08:24 by author Peter

I'm using Windows 10 Enterprise Edition in my instance. Now launch the browser and enter http://localhost/ as the URL.

A page not found error will appear when you press Enter.
I'm going to look for the IIS manager now.

Not located!
Slide the Control Panel open.

Click Programs.


Under Programs and Features, click Turn Windows features on or off.

A new popup will appear.


Just check the Internet Information Services and its related features. Under Internet Information Services check the following folders.

  • FTP Server
  • Web Management Tools
  • World Wide Web services
  • Application development features
  • Common HTTP Feature
  • Health and Diagnostics
  • Performance Feature
  • Security

Then click OK to complete the installation of new features.


Click Restart now to apply changes to complete the IIS feature installation.

After a successful restart.
Now you can see the IIS webserver option on the All Programs menu.
Open the browser.
Now type URL http://localhost.

Internet Information Services (IIS) successfully configured.

Summary

In this article, we learned about Configure IIS In the Windows 10 Operating System.



IIS Hosting Europe - HostForLIFE :: How to Configure Permission For the Website on IIS?

clock May 31, 2024 09:59 by author Peter

This article will teach you how to set up permissions on an IIS website.

Step 1: From the Start Menu, first select the Administrative Tools.

In the Administrative Tools Wizard an option will be available named IIS Manager; double-click on it to open it.

Step 2. Now the IIS Manager Wizard will be opened, here on the left-hand side the Connections Pane will be available, and the Connection Pane will show your Server Name.

Expand your Server's Name. Now you will see a folder named Sites, expand this folder it will contain all the sites you have configured on IIS, right now I haven't configured any websites so only the Default Website is available under it.

Step 3. Now right-click on the Website and choose "Edit Permissions".

Now the Property Window will be opened, here by default the General Tab will be open. You need to click on the Security Tab.

 

Step 4. Now the Group and User Names will be shown to you. To change the permission, click on any of the User or Group names and then click on the Edit Button.

On clicking the Edit button a new page will be opened, here you can Add or Remove a User from the list. You can also provide various kinds of permissions to the user by clicking the check box present in front of each permission, if you want to provide all the permissions then simply click on the Full Control and then click on the Apply Button, and then on the "Ok" button.

Step 5. When you click on the "OK" button it will return you to the Property Window, if you want to provide special permission to any user then you can simply click on the Advanced Button.

In the New Wizard select the user whose permission is to be modified and then click on the Edit Button. From here also you can Add or remove any user.




IIS Hosting Europe - HostForLIFE :: How to Start and Stop Only One Application Under the Website Root Node?

clock March 4, 2024 09:14 by author Peter

How can I start and stop only one application under a website's root node?

 
Procedure

Open IIS by typing "inetmgr" into the Run box and clicking OK, as seen in the figure below.

The IIS window will be opened.
Create a new application pool for the application that you want to stop. Right-click on Application Pool then select New -> Application Pool as shown in the following image.

Provide the appropriate name to your application pool and keep the other settings that are the defaults in the window, as shown in the following image. Click OK.

Your application pool will be created now as shown in the following image. You can observe that there is no application related to this newly created application pool. See the right-hand side. It is showing that “There are no items to shown in this view.”.


Now you need to relate this newly created application pool to the application that you want to stop. Select the application that you want to stop. Right-click then select Properties. See the following image. The following window will be opened as shown in the following image.

Click on the Create button.
 
Automatically Application Name will be enabled by IIS and it is the name of the application by default for which you are doing this activity. You can change it as you prefer. Also, the Application Pool dropdown is now enabled.
 
Now select the Application Pool that you created earlier from the Application Pool dropdown list as shown in the following image.

Click OK.
Now to stop that only application, right-click on the Application Pool name then select Stop as shown in the following image.


To start the application, right-click on the Application Pool name then select Start. In this way, you can start and stop only one application under IPlanetWebsite in which many applications are deployed under it.



IIS Hosting Europe - HostForLIFE :: Publish and Deploy.NET 6 Web Application on IIS and Access Using Ngrok

clock February 22, 2024 07:00 by author Peter

The first step is to sign up for Ngrok and provide your information.

Click to Signup, and after Sign in, download the Ngrok.

Ngrok is downloaded, so extract this folder.

After extracting browse the folder and find the file mentioned below.

Double-clicking the executable file will open up CLI.

Run this command to add authentication on the command prompt.

After executing the above command, authentication will be added for you.

Run the following command for HTTP Tunnel forwarding.


This command will forward port 80, where a locally deployed application can be accessed from the internet.

Now create a new .Net 6 Application for publishing and deploying on IIS and accessing it using Ngrok from the internet.

Select the path for saving the Application files.

Select .NET 6.0 and click on the Create button.


A .NET 6.0 Application is created.

Click to run this Application.

Now Application is running on localhost that is not deployed on IIS yet.

Now select the project and click to publish it.

Select your desired location to publish your application package. As I created a new folder with the highlighted name.

Select the Folder location to publish the application.

Publish Profile is created.

Click to Publish button to Publish the application.

 

Click to Open Folder where application files are published.

You will find the files at the location.

Now open IIS by pressing the Window button and search for IIS that must be already installed on your local machine. If it is not installed, please install and configure it properly for publishing the application locally. Now browse it.

Now right-click on Default Website and click on Add Application.

Give the Application Alias, select the Application pool, and provide the physical path where we published our application.

Now our application has been published on IIS.

Now right-click on the DemoApplication and browse it. You can see that our application is running on IIS with Alias, as it was given before publishing.

Now we want to access this application via ngrok. Copy the URL provided by ngrok.

Now, in the browse window, paste the URL with your published application alias and press enter. You can now view if your application is still responding and operating, as well as its URL. Note: When you run Ngrok again, the URL may change.



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.



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