Running Angular on an IIS web server

Step 1.
Build your angular application for “production”:
ng build –dist -> output entire site to root/dist folder copy that folder to your IIS website folder.

Step 2.
IIS uses a file called web.config to setup some configuration for a website.
Make sure you have something similar as below in a web.config file in the site root folder (a typical Angular config scenario):

<configuration>
  <system.webServer>
    <!-- These rewrite rules requires the IIS Rewrite module -->
    <rewrite>
      <rules>
        <!-- Support for Angular internal url routing system (routing module) -->
        <rule name="Angular routing" 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>
        <!-- Adds https scheme if missing for all URLs -->
        <rule name="FQDN to SSL" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
      </rules>
    </rewrite>
    <!-- Mime type fix for woff2 font file type -->
    <staticContent>
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
    </staticContent>
  </system.webServer>

  <!-- Its okay to cache these static files, index.html will include cache busting paths for Angular js and css files. (when building with --dist param) -->
  <system.webServer>
    <caching enabled="true">
      <profiles>
        <add extension=".svg" policy="CacheUntilChange"/>
        <add extension=".ico" policy="CacheUntilChange"/>
        <add extension=".js" policy="CacheUntilChange"/>
        <add extension=".css" policy="CacheUntilChange"/>
      </profiles>
    </caching>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" />
    </staticContent>
  </system.webServer>

  <!-- Make sure index.html is never cached -->
  <location path="index.html">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="DisableCache" cacheControlMaxAge="0.00:00:00" />
      </staticContent>
      <httpProtocol>
        <customHeaders>
          <add name="Cache-Control" value="no-cache, no-store, must-revalidate" />
          <add name="Pragma" value="no-cache" />
          <add name="Expires" value="-1" />
        </customHeaders>
      </httpProtocol>
    </system.webServer>
  </location>

</configuration>

 

Deploy an Angular Application to IIS – Angular In Depth

Getting your Angular Router application actually working in a non-root folder on Internet Information Services

The Angular Router is a fantastic module for Single Page Apps. However, to deploy it in a Production scenario you will typically need to do some configuration to make it work. This article details the steps necessary to deploy an Angular Router application anywhere on Internet Information Services (IIS).

Source: Deploy an Angular Application to IIS – Angular In Depth

WFetch – Simple Microsoft Tool for troubleshooting HTTP connections

Wfetch is originally part of the IIS 6.0 Resource Kit Tools.
It can be used to troubleshoot http redirects, http status codes etc.

This simple but powerful testing tool is a must-have for any system administrator or Web site manager. Wfetch’s simple GUI offers easy input and clear output to test almost any Web host. Don’t expect a manual or clear failure information. This tool was released for expert users.Operating Wfetch is actually very simple, providing you understand Web functions such as Get, Put, Head, Trace, Post, and others. It’s a mere matter of using a few pull-downs, entering some simple text and pressing Go. The trick comes when users must interpret the Log Output from their commands. If Get HTTP/1.1\r\n makes sense, this app was written for you. The utility offers numerous authentication and connection features. Additional commands make it easy to copy and paste text from the output log file.Wfetch is not secure as it stores user names and passwords in plain text. Nevertheless, it is an invaluable freeware tool for any user looking to diagnosis certain connection problems.

Source: WFetch – Free download and software reviews – CNET Download.com

More info:
https://support.microsoft.com/en-in/help/284285/how-to-use-wfetch-exe-to-troubleshoot-http-connections

 

How to solve 500 – Internal Server Error in ASP.NET: Troubleshooting Failed Requests Using Tracing in IIS 7 : The Official Microsoft IIS Site

If nothing of value comes up in your errorlogs or in the event viewer. Just follow this guide to enable Tracing in IIS7+

Source: Troubleshooting Failed Requests Using Tracing in IIS 7 : The Official Microsoft IIS Site

Simple tool for analyzing IIS logs

The IIS server logs looks something like this:

#Software: Microsoft Internet Information Services 8.0
 #Version: 1.0
 #Date: 2016-04-19 00:47:15
 #Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

This simple to use tool parses those logfiles and creates a html file that opens in the web browser and presents the data in a nice simple way complete with graphs.

Download “WebLog Expert Lite” for free.

Source: WebLog Expert Download

IIS Add to Hosts File Extension

Here’s a simple module to solve a recurrent and an annoying everyday task in IIS management: creating an entry in the Windows TCP/IP Hosts file for every demo and test web site.


This module extends the IIS Manager UI in order to add an entry on request in the Hosts file located in%SystemRoot%\System32\drivers\etc\hosts when a web site is created or its bindings are edited.”

WebsiteAdd2.png

IIS Hosts File Manager – Home.

Newer working link:
https://github.com/richardszalay/iishosts