<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss version="2.0">
  <channel>
    <title>Rick Strahl's Web Log</title>
    <link>https://weblog.west-wind.com/</link>
    <image>
      <url>ImageUrl</url>
      <title>Rick Strahl's Weblog</title>
      <link>https://weblog.west-wind.com/</link>
    </image>
    <description>Wind, waves, code and everything in between</description>
    <copyright>(c) West Wind Technologies 2006-2026</copyright>
    <pubDate>2026-09-03T05:18:40.741383Z</pubDate>
    <lastBuildDate>2026-09-01T10:00:00Z</lastBuildDate>
    <generator>Rick Strahl's West Wind Weblog</generator>
    <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" content="noindex" name="robots"/><item>
      <title>Back to Basics: JavaScript and Timezones</title>
      <description><![CDATA[<p><img src="https://weblog.west-wind.com/imageContent/2026/JavaScript-and-Timezones/TimeZoneBanner.jpg" alt="Time Zone Banner"></p>
<p>Classic native <code>Date</code> values in JavaScript are internally represented as UTC dates. However, when you display values they are by default shown as local date/time values. I've run into this recently again with an application that was returning a mix of UTC and non-UTC dates from the server to the browser, causing some confusion. At that point I realized I was being inconsistent with my use of the my date display functions, and here I am reviewing various Date formatting and Date conversion operations.</p>
<p>JavaScript's core behavior is consistent once you separate two different concepts:</p>
<ul>
<li>The instant represented by a Date</li>
<li>The timezone used to display that instant</li>
</ul>
<p>An instant is essentially an instant in time expressed in an offset since the <strong>Unix Epoch</strong>:</p>
<p><strong>January 1, 1970 00:00:00 UTC</strong></p>
<p>The instant is represented via <code>new Date().getTime()</code> or a more precise value of <code>Temporal.Instant</code> which represents the unique point in time, with nanosecond precision. It is fundamentally represented as the number of nanoseconds since the Unix epoch (midnight at the beginning of January 1, 1970, UTC), without any time zone or calendar system.</p>
<p><a href="https://markdownmonster.west-wind.com?ut=weblog"  target="_blank"
	  title="Markdown Monster - Easy to use, yet powerfully productive Markdown Editing for Windows">
<img src="https://weblog.west-wind.com/images/sponsors/MarkdownMonster-Display2.jpg" class="da-content-image" />
</a></p>
<p>The most common usage of dates is via the <code>Date</code> object and its methods. Dates are stored as UTC values, but standard display of dates in the browser UI or via the debug tools shows dates in <strong>local time</strong>.</p>
<p>So when you output a date it looks like this (<code>PST</code> or <code>America/Los Angeles</code> timezone in this case):</p>
<pre><code class="language-js">new Date()
// Mon Aug 24 2026 11:33:26 GMT-0700 (Pacific Daylight Time)
</code></pre>
<p>my current <code>PST</code> timezone value is displayed with <code>toString()</code> or any string concat operation. Notice that the date formatter automatically adjusts for Daylight savings time of the active timezone.</p>
<p>I also get a time adjusted value, if I explicitly convert the value using <code>toLocaleTimeString()</code> which gives me just the time value as a string:</p>
<pre><code class="language-js">new Date().toLocaleTimeString()
// '11:33:46 AM'
</code></pre>
<p>I can also go the other way - if I want to actually display the UTC value I can use the following:</p>
<pre><code class="language-js">new Date().toLocaleTimeString(undefined, { timeZone: &quot;UTC&quot; });
'6:33:43 PM'
</code></pre>
<p>I can also specify any specific defined timezone using the familiar timezone abbreviations:</p>
<pre><code class="language-js">new Date().toLocaleTimeString(undefined, { timeZone: &quot;EST&quot; });
// '1:34:02 PM'
</code></pre>
<p>or using a full <a href="https://timeapi.io/documentation/iana-timezones">IANA Time Zones</a> identifier:</p>
<pre><code class="language-js">new Date().toLocaleTimeString(undefined, { timeZone: &quot;America/New_York&quot; });
// '1:34:02 PM'
</code></pre>
<blockquote>
<h5 id="--get-your-local-timezone"><i class="fad fa-lightbulb" style="font-size: 1.1em"></i>  Get your Local Timezone</h5>
<p>If you're like me you're probably used to seeing timezone values represented by their shortcut names like <code>PST</code>, <code>EST</code>, <code>CET</code> etc., but officially JavaScript uses <a href="https://timeapi.io/documentation/iana-timezones">IANA Time Zones</a> which are represented like <code>America/Los_Angeles</code>, <code>Pacific/Honolulu</code>, <code>Europe/Berlin</code> etc. There are actually many overlapping formats such as <code>Pacific/Honolulu</code>, <code>US/Hawaii</code> and <code>HST</code> for my Hawaii timezone that all represent the same UTC -10 timezone.</p>
<p>I'm in Hood River (near Portland, OR) currently, but the active PST timezone that gets returned is <code>America/Los_Angeles</code>, which seems semantically very wrong, but does represent the correct UTC -8 timezone.</p>
<p>You can find out the local timezone like this:</p>
<pre><code class="language-js">Intl.DateTimeFormat(undefined, { timeZoneName: &quot;short&quot; })
   .resolvedOptions().timeZone;
// 'America/Los_Angeles'
</code></pre>
<p>or for the abbreviation.</p>
<pre><code class="language-js">new Intl.DateTimeFormat(undefined, { timeZoneName: &quot;short&quot; })
.formatToParts(new Date())
.find(x =&gt; x.type === &quot;timeZoneName&quot;)?.value;
// PDT
</code></pre>
</blockquote>
<h2 id="dates-are-instants-display-is-local">Dates are Instants, Display is Local</h2>
<p>The most important thing to keep in mind is this:</p>
<pre><code class="language-js">const date = new Date(&quot;2026-08-24T18:33:46.000Z&quot;);

date.toISOString();
// '2026-08-24T18:33:46.000Z'

date.toString();
// 'Mon Aug 24 2026 11:33:46 GMT-0700 (Pacific Daylight Time)'
</code></pre>
<p><code>toISOString()</code> returns the instance UTC value with no date time offset regardless of whether the instance has a timezone or not ie. <code>2026-08-24T18:33:46.000Z</code>. The <code>Z</code> at the end indicates the UTC timezone.</p>
<p><code>toString()</code> and most other date output functions return <strong>local time</strong> values adjusted for the current timezone.</p>
<p>This is where JavaScript can be confusing because many <code>Date</code> methods are split between local-time and UTC-time versions:</p>
<pre><code class="language-js">const date = new Date(&quot;2026-08-24T18:33:46.000Z&quot;);

date.getHours();
// 11   local time for me

date.getUTCHours();
// 18   UTC time
</code></pre>
<p>Yeah that <code>.getHours()</code> value is confusing if the time instance is a UTC value, but the bottom line is that any of the 'standard' date operations use local dates unless you explicitly use the UTC or ISO functions.</p>
<p><a href="https://documentationmonster.com?ut=weblog"  target="_blank"
	  title="Documentation Monster - Creating documentation one Markdown at a time">
<img src="https://weblog.west-wind.com/images/Sponsors/DocumentationMonster-Display2.jpg" alt="Documentation Monster" class="da-content-image" />
</a></p>
<h2 id="formatting-dates-with-intldatetimeformat">Formatting Dates with Intl.DateTimeFormat</h2>
<p>You can use <code>toLocaleString()</code> to format dates and times, but if you want more control you can use the <code>Intl.DateTimeFormat</code> object which makes formatting more explicit and reusable.</p>
<pre><code class="language-js">const formatter = new Intl.DateTimeFormat(undefined, {
	dateStyle: &quot;medium&quot;,
	timeStyle: &quot;short&quot;
});

formatter.format(new Date(&quot;2026-08-24T18:33:46.000Z&quot;));
// 'Aug 24, 2026, 11:33 AM'  // on my machine
</code></pre>
<p>The first parameter of the constructor is the <strong>locale</strong> ie. <code>en-US</code> or <code>de-DE</code>. Passing <code>undefined</code> use the current user's locale.</p>
<p>To override for a specific timezone you can explicitly specify it as part formatting parameters for <code>timeZone</code>. To explicitly show <code>UTC</code> time:</p>
<pre><code class="language-js">const utcFormatter = new Intl.DateTimeFormat(undefined, {
	year: &quot;numeric&quot;,
	month: &quot;short&quot;,
	day: &quot;numeric&quot;,
	hour: &quot;numeric&quot;,
	minute: &quot;2-digit&quot;,
	timeZone: &quot;UTC&quot;,
	timeZoneName: &quot;short&quot;
});

utcFormatter.format(new Date(&quot;2026-08-24T18:33:46.000Z&quot;));
// 'Aug 24, 2026, 6:33 PM UTC'
</code></pre>
<p>To show a specific user's timezone formatted for a specific locale:</p>
<pre><code class="language-js">const newYorkFormatter = new Intl.DateTimeFormat(&quot;en-US&quot;, {
	year: &quot;numeric&quot;,
	month: &quot;short&quot;,
	day: &quot;numeric&quot;,
	hour: &quot;numeric&quot;,
	minute: &quot;2-digit&quot;,
	timeZone: &quot;America/New_York&quot;,
	timeZoneName: &quot;short&quot;
});

newYorkFormatter.format(new Date(&quot;2026-08-24T18:33:46.000Z&quot;));
// 'Aug 24, 2026, 2:33 PM EDT'
</code></pre>
<h3 id="serve-me-this-client-me-that">Serve me this, Client me That</h3>
<p>The way that timezone display works in browsers makes sense 99% of the time as you typically want to display the timezone as local in the client browser.</p>
<p>But it gets a lot more complicated when the dates are server rendered or passed from the server to the client via API calls. The issue here is that the dates on the server might be stored for a specific timezone and perhaps are even returned with that timezone information encoded into the JSON payload.</p>
<p>This is why most applications store dates dates as UTC and then adjust the value on the client or on the server based on user preferences configured.</p>
<p>UTC dates are most consistent, but for users displaying a UTC date is definitely not ideal. It might work for logs or other systems related information, but for end users local time or a selected timezone display is a requirement.</p>
<p>For many applications I like the second option for user-facing screens: send the timestamp as UTC or ISO 8601 in the HTML, then let client-side JavaScript render it into the user's actual local timezone - potentially adjusted for a user specified timezone.</p>
<p>For example:</p>
<pre><code class="language-html">&lt;time datetime=&quot;2026-08-24T18:33:46.000Z&quot; class=&quot;local-time&quot;&gt;
	2026-08-24 18:33 UTC
&lt;/time&gt;
</code></pre>
<p>and then for browser local time:</p>
<pre><code class="language-js">const formatter = new Intl.DateTimeFormat(undefined, {
	year: &quot;numeric&quot;,
	month: &quot;short&quot;,
	day: &quot;numeric&quot;,
	hour: &quot;numeric&quot;,
	minute: &quot;2-digit&quot;,
	timeZoneName: &quot;short&quot;
});

document.querySelectorAll(&quot;time.local-time&quot;).forEach(element =&gt; {
	const date = new Date(element.dateTime);
	element.textContent = formatter.format(date);
});
</code></pre>
<p>For a specific timezone you can specify the timezone in the constructor:</p>
<pre><code class="language-js">let timeZone = userConfig.timeZone;
const formatter = new Intl.DateTimeFormat(undefined, {
	year: &quot;numeric&quot;,
	month: &quot;short&quot;,
	day: &quot;numeric&quot;,
	hour: &quot;numeric&quot;,
	minute: &quot;2-digit&quot;,
    timeZone: timeZone,  // America/Los Angeles or PST
	timeZoneName: &quot;short&quot;
});
</code></pre>
<p>This gives non-JavaScript clients and crawlers a useful UTC fallback, while normal browser users get a local or user specified timezone display value.</p>
<h4 id="getting-the-users-timezone-for-the-server">Getting the user's TimeZone for the Server</h4>
<p>In order for client applications to provide the timezone to the server you can detect the value on the client like this:</p>
<pre><code class="language-js">Intl.DateTimeFormat().resolvedOptions().timeZone;
// 'America/Los_Angeles'
</code></pre>
<p>and then send that to the server. AFAIK the client does not send timezone information to the server as part of browser headers by default, so some explicit API call or similar operation is required to communicate the default to the server.</p>
<h2 id="new-javascript-apis">New JavaScript APIs</h2>
<p>The classic JavaScript <code>Date</code> object has been around forever and it's not going away. It works fine for many things, especially if you treat it as an instant and use <code>Intl.DateTimeFormat</code> for display.</p>
<p>But <code>Date</code> is a pretty limited API. It mixes parsing, timestamps, local timezone accessors, UTC accessors, mutable setters, and display helpers into a single object. That's a lot of behavior packed into one small type.</p>
<h3 id="the-newish-temporal-api">The newish Temporal API</h3>
<p>The newer API to keep an eye on is <code>Temporal</code>. Depending on the JavaScript runtime you're targeting you may still need a polyfill, so <a href="https://caniuse.com/temporal">check current browser and runtime support</a> before using it directly in production code. But conceptually it's a much better model because it separates the things that <code>Date</code> blends together.</p>
<p>The important Temporal types are:</p>
<ul>
<li><code>Temporal.Instant</code> - a point in time, like a better <code>Date</code> timestamp</li>
<li><code>Temporal.PlainDate</code> - a calendar date without time or timezone</li>
<li><code>Temporal.PlainDateTime</code> - a date and time without timezone</li>
<li><code>Temporal.ZonedDateTime</code> - a date and time in a specific timezone</li>
</ul>
<p>That separation maps much more cleanly to real application data.</p>
<p>For example, an instant displayed in a timezone:</p>
<pre><code class="language-js">const instant = Temporal.Instant.from(&quot;2026-08-24T18:33:46.000Z&quot;);

const localTime = instant.toZonedDateTimeISO(&quot;America/Los_Angeles&quot;);
localTime.toString();
// '2026-08-24T11:33:46-07:00[America/Los_Angeles]'
</code></pre>
<p>A plain date that doesn't accidentally roll back a day:</p>
<pre><code class="language-js">const birthday = Temporal.PlainDate.from(&quot;2026-08-24&quot;);
birthday.toString();
// '2026-08-24'
</code></pre>
<p>And a timezone-aware future event:</p>
<pre><code class="language-js">const meeting = Temporal.ZonedDateTime.from({
	year: 2026,
	month: 8,
	day: 24,
	hour: 9,
	minute: 0,
	timeZone: &quot;America/New_York&quot;
});

meeting.toInstant().toString();
// '2026-08-24T13:00:00Z'
</code></pre>
<p>Even if you don't use Temporal yet, the model is useful: decide whether your value is an instant, a plain date, a local date/time, or a timezone-aware date/time. That decision prevents a lot of downstream confusion.</p>
<p>PlainDate/PlainDateTime is an odd one - it's time instant <strong>without any time zone associated with it</strong>. It's not UTC, but it's also not specifically tied to any other time zone. These values always print exactly what the values are without any transformation. One example where that's useful is Birthdays, which always are on a certain date and regardless of time zone adjustment stay on that particular date.</p>
<p>Personally I've not used Temporal, yet, but looking at the API I sure can see that it's useful because it allows you to be precise about what type of date you're dealing with. An Instant timestamp, a Plain date or date time value or a timezone specific date and time with the corresponding date formatting string functions to match.</p>
<p><a href="https://amzn.to/4etxlQA"  target="_blank"
		  title="Sign up for an Amazon Visa - 5% cash back for Amazon and Whole Food Purchases">
<img src="https://weblog.west-wind.com/images/sponsors/AmazonPrimeVisa-Display.jpg" class="da-content-image" />
</a></p>
<h2 id="summary">Summary</h2>
<p>JavaScript has a fair amount of options for formatting dates and dealing with dates in various time zone formats. The basic <code>Date</code> type is limited to using UTC or local time formats, but using <code>INTL.DateTimeFormat</code> allows you to create specific time instances that can be set to specific timezones which allows you to adjust dates based on user preferences beyond just the default browser time zone.</p>
<p>The <code>Temporal</code> class adds a more specific API for representing Date and Timezone values as a single instance, and goes beyond just displaying timezone adjusted values. I haven't run into a particular use case where this matters, as I typically use UTC dates and only need to display timezone adjusted values, but if you're passing date time values around between different APIs this might be useful.</p>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="https://timeapi.io/documentation/iana-timezones">IANA Time Zones</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat">Intl.DateTimeFormat()</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal">Temporal</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Instant">Temporal.Instance</a></li>
</ul>
<div style="margin-top: 30px;font-size: 0.8em;
            border-top: 1px solid #eee;padding-top: 8px;">
    <img src="https://markdownmonster.west-wind.com/favicon.png" style="height: 20px;float: left; margin-right: 10px;">
    this post was created and published with the 
    <a href="https://markdownmonster.west-wind.com" target="top">Markdown Monster Editor</a> 
</div>
]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Sep/01/JavaScript-and-Timezones</link>
      <guid isPermaLink="false">u33738s1e975</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Sep/01/JavaScript-and-Timezones#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Sep/01/JavaScript-and-Timezones</guid>
      <pubDate>Tue, 01 Sep 2026 00:00:00 GMT</pubDate>
      <abstract><![CDATA[JavaScript's native `Date` object internally tracks UTC instants but defaults to local time for display, leading to common timezone pitfalls. In this post, I describe how to manage and display timezones using various JavaScript APIs old and new from the old and trusty `Date` object, `INTL.DateTimeFormat()` and the newish `Temporal` class.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/imageContent/2026/JavaScript-and-Timezones/TimeZoneBanner.jpg</featuredImage>
    </item>
    <item>
      <title>Getting Inherited Controller Routes to work in ASP.NET Core</title>
      <description><![CDATA[<p><img src="https://weblog.west-wind.com/imageContent/2026/Getting-Inherited-Controller-Routes-to-work-and-ASP-NET-Core/Banner.jpg" alt="Banner"></p>
<p>By default ASP.NET applies Controller Attribute Routes on concrete types. If you create a Controller class, the class and its routes are automatically recognized by ASP.NET during the startup process.</p>
<p>ASP.NET scans the startup assembly for any instance controllers and adds the routes it finds on them to the route table. If you have Controllers that live in another assembly you can get those to register as well, but you have to explicitly add the assembly to be scanned to the MVC startup configuration in your startup code:</p>
<pre><code class="language-csharp">var mvcBuilder = services.AddControllersWithViews()
    // have to let MVC know we have an externally loaded controller
    .AddApplicationPart(typeof(QmmApiController).Assembly);
</code></pre>
<p>Things get more complicated when you want to <strong>inherit</strong> controllers as it's not always obvious how routed endpoints are making their routes available in an inherited class.</p>
<p>In this post I discuss some of the issues you have to watch out for if your want to inherit controllers with routes from base classes either in the same project or an external library/project.</p>
<p><a href="https://markdownmonster.west-wind.com?ut=weblog"  target="_blank"
	  title="Markdown Monster - Easy to use, yet powerfully productive Markdown Editing for Windows">
<img src="https://weblog.west-wind.com/images/sponsors/MarkdownMonster-Display2.jpg" class="da-content-image" />
</a></p>
<h2 id="controller-inheritance">Controller Inheritance?</h2>
<p>Controller inheritance is not a common use case for most people, but yet I find myself frequently using it to provide default Admin APIs or default UI behavior for templating and error handling in various generic components and application templates.</p>
<p>For example, in my <a href="https://github.com/RickStrahl/Westwind.AspNetCore.Markdown">Westwind.AspNetCore.Markdown</a> library, a base Controller class provides the default template processing and styling for the default Markdown file rendering. In another project which is a messaging solution, a base controller provides an optional REST interface for the messaging APIs that otherwise use SignalR. In both of these cases,  Controllers are shipped as part of a separate library project that is referenced via NuGet in a top level project.</p>
<p>In both of these cases, you have the option of overriding both the functionality and in the case of the Markdown templating library provide a custom View to customize behavior and/or UI.</p>
<h3 id="controllers-vs-minimal-apis">Controllers vs. Minimal APIs</h3>
<p>I realize a lot of people will scoff at using Controllers as being old fashioned, but for packaged functionality like this, Controllers are way easier to manage and to extend than creating a slew of middleware related components along with complex configuration instructions to handle extensibility. Controllers provide a rich, extensive native interface, and you can easily subclass to extend functionality. All of that comes out of the box, so for components that need Http behavior <strong>generically</strong> provided for me Controllers are my go-to.</p>
<p>One additional reason very relevant for this post is that  using controllers it's possible to override routes. ASP.NET does not allow for duplicate routes to be defined and blows up one way or another if they are created, but with controllers there are ways that you can override this behavior,  that allow you to either inherit or override routes as I discuss in this post.</p>
<p>AFAIK, this is not really possible with <code>app.Map()</code> short of explicitly mucking with the route definitions.</p>
<h2 id="my-use-case-and-how-i-ended-up-here">My Use Case and how I ended up here</h2>
<p>As a result, I'm using Controllers for my generic API functionality in a messaging solution. As mentioned this is a REST API defined in a library class that is imported with:</p>
<pre><code class="language-csharp">var mvcBuilder = services.AddControllersWithViews()
    // have to let MVC know we have an externally loaded controller
    .AddApplicationPart(typeof(QmmApiController).Assembly);
</code></pre>
<p>The scenario I'm working with is the following:</p>
<ul>
<li>I have a base controller class <code>public class QmmApiController : BaseApiController</code><br>
in a separate assembly that provides a base admin interface. It has a bunch of <code>[Route()]</code> attributes attached to it provide base API functionality.</li>
<li>I then inherit from this controller <code>public class SampleAppQmmApiController : QmmApiController</code><br>
in the top level ASP.NET application</li>
</ul>
<p>When I try to access the routes defined in the base class as defined I end up with a <code>500 Internal Server Error</code>:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Getting-Inherited-Controller-Routes-to-work-and-ASP-NET-Core/RoutingErrorOnIheritedRoutes.png" alt="Routing Error On Iherited Routes"><br>
<small><strong>Figure 1</strong> - Routes from inherited controllers will throw a 500 error. API Access here via <a href="https://websurge.west-wind.com">WebSurge</a>.</small></p>
<p>Not a 404, but a 500... which is a <strong>pretty harsh</strong> result! 😄</p>
<p>If I take a closer look at the issue in the Console, I can see this log error output on the server:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Getting-Inherited-Controller-Routes-to-work-and-ASP-NET-Core/AmbigousRouteException.png" alt="Ambigous Route Exception"><br>
<small><strong>Figure 2</strong> - After inheriting from a concrete base class, I ended up with AmbiguousRoute exceptions</small></p>
<p>The <strong>ambiguous</strong> route exception is a clear hint that I - and also various LLMs - missed initially. Note that unfortunately it doesn't mention <strong>which routes</strong> are failing even though it looks like it's supposed to.</p>
<p>More on this failure a little bit later. But for now, realize that the routes defined on the base class are failing in the inherited class.</p>
<h2 id="controller-attribute-routes-and-inheritance">Controller Attribute Routes and Inheritance</h2>
<p>As it turns out using controllers with inherited Route definitions are tricky to work with. As you can see in Figure 1 and Figure 2, the routes defined on the base class are all failing. Any routes that are <strong>explicitly</strong>  defined on the concrete, top level controller work fine. Any routes defined on the concrete base class fail.</p>
<p>So what's going on here?</p>
<p>My initial thought was that ASP.NET <strong>wasn't picking up the base class routes</strong>. In fact, both I and various LLMs <strong>completely misdiagnosed the problem</strong> by assuming the <strong>routes were missing</strong> and trying to actually add the routes explicitly into the route table. That did not work!</p>
<p>After a lot of back and forth with various agents, and a lot of manual <code>Console.Writeline()</code> outputs trying to track down Routes and Endpoint mappings, it turns out that the problem is not missing routes but actually <strong>Route Duplication</strong>!</p>
<h3 id="the-problem-route-duplication">The Problem: Route Duplication</h3>
<p>When you subclass a Controller the Attribute Routes defined on it are inherited by the child class, you now effectively have two sets of Attribute Routes: One on the base class and one on the parent class! ASP.NET detects routes on the entire class inheritance structure (as it should), so for the concrete class it picks up any routes that are explicitly defined on the concrete class <strong>and</strong> the routes from the inherited class.</p>
<p>ASP.NET then also picks up the base class as a separate concrete class and maps the routes defined on it.</p>
<p><strong>And Bingo: You now have route duplication!</strong></p>
<p>This is why we're seeing the <strong>Ambiguous Route Error</strong> shown in <strong>Figure 2</strong>.</p>
<h3 id="controller-inheritance-its-complicated">Controller Inheritance... It's complicated</h3>
<p>So the problem is the inheritance, but it's not quite as cut and dried as that either. There's more nuance.</p>
<p>In the example above - which was my original use case - the base class was a concrete instance class:</p>
<p>I define my top level application class like this:</p>
<pre><code class="language-cs">public class SampleQmmApiController : QmmApiController {}
</code></pre>
<p>And I'm inheriting from this base class:</p>
<pre><code class="language-cs">public class QmmApiController : BaseApiController {}
</code></pre>
<p><strong>That doesn't work</strong> and gives the <strong>Ambiguous Route</strong> error.</p>
<p>But if I use an <code>abstract</code> base class to inherit from, Attribute Routes are not duplicated and an inherited controller can correctly see a single set of inherited routes projected by the inherited concrete instance:</p>
<pre><code class="language-cs">public abstract class QmmApiController : BaseApiController {}
</code></pre>
<p>If you inherit this abstract class <strong>the routes now work</strong>!</p>
<p>Here's a table that summarizes the various modes:</p>
<table>
<thead>
<tr>
<th style="text-align: left;">Library Inheritance</th>
<th style="text-align: left;">Base Class Type</th>
<th style="text-align: left;">Result</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;"><strong>No Inheritance</strong></td>
<td style="text-align: left;">Concrete</td>
<td style="text-align: left;">Works (Routes recognized on library class)</td>
</tr>
<tr>
<td style="text-align: left;"><strong>No Inheritance</strong></td>
<td style="text-align: left;">Abstract</td>
<td style="text-align: left;">not picked up by ASP.NET</td>
</tr>
<tr>
<td style="text-align: left;"><strong>Inherited</strong></td>
<td style="text-align: left;">Concrete</td>
<td style="text-align: left;"><strong>Doesn't work</strong> (Routes on base class are ignored)</td>
</tr>
<tr>
<td style="text-align: left;"><strong>Inherited</strong></td>
<td style="text-align: left;">Abstract</td>
<td style="text-align: left;">Works (Routes recognized on child class)</td>
</tr>
</tbody>
</table>
<p>The <strong>No Inheritance</strong> scenario works both for project local or imported from an external library controllers as long as <code>.AddApplicationPart()</code> has imported the assembly. With an instance class the routes are <strong>always-on</strong>. Makes sense - this is how controller routes are discovered by default. But in the case of an external library that exposes a controller it might be a little unexpected  that any public instance controller you have in the library automatically is available for processing.</p>
<p>For an external library the better path most likely is to use an <code>abstract class</code>, which ASP.NET's parser will not automatically add to the route table. This effectively hides the routing interface and lets you explicitly enable the routes by subclassing the controller in your top level project.</p>
<p>Which works best depends on the scenario. For example, in my Markdown template controller I want the routes to be always active so the Markdown processing can occur. As a result I use an instance class controller. But in my queue controller scenario I want the host application to decide whether the REST API is available to access, so I use an abstract class controller.</p>
<p>Subclassing in both of these use cases provides the abililty to override default behavior - for the Markdown component the template usage, for the API how authentication and tokens are handled - which are common customizations for these two.</p>
<h3 id="preserving-base-class-routes">Preserving Base Class Routes</h3>
<p>There are actually a couple of ways that you can subclass a controller and preserve the base class routes:</p>
<ul>
<li><p><strong>Define your base class as <code>abstract</code></strong><br>
Abstract base classes are not picked up by ASP.NET when enumerating routes, so an abstract class when inherited can safely bring in the base class routes and you can use the endpoints as is, or override them. <strong>It just works.</strong></p>
</li>
<li><p><strong>Inheriting Non-Abstract Controllers requires custom Route Manipulation</strong><br>
If you decide you can't use an abstract class because you want routes to be <strong>always-on</strong> by default and still have the ability to inherit, there's a way to make this work by intercepting and modifying routes ASP.NET has auto-discovered.</p>
</li>
</ul>
<h3 id="abstract-classes-are-easiest">Abstract Classes are Easiest</h3>
<p>If you build library components and you want to conditionally expose routes on controllers, using an abstract base class is the easiest way to do it. By marking the controller as <code>abstract</code> and creating a concrete implementation class you are delegating the routes explicitly to where they are required, bypassing potentially unintended conflicts.</p>
<p>The downside is that you have to explicitly implement a subclass and that requires some sort of documentation so that users know that this is necessary to enable the base behavior.</p>
<h3 id="creating-an-iactiondescriptorprovider-route-interceptor">Creating an IActionDescriptorProvider Route Interceptor</h3>
<p>In order to deal with non-abstract instance Controlller base classes, we need to manipulate the ASP.NET route table <strong>after</strong>  ASP.NET has picked up all the routes.</p>
<p>Recall that the issue is that routes get <strong>duplicated</strong> if you inherit and instance class that contains routes: You end up with the base class' routes added to the route table, and then again from the inherited class when ASP.NET scans for controller classes.</p>
<p>So to detect and remove the duplicated routes we can:</p>
<ul>
<li>Implement <code>IActionDescriptorProvider</code> to intercept completed Routes after auto-detection</li>
<li>Remove base class routes for all or specific classes</li>
</ul>
<p><code>IActionDescriptorProvider</code> lets you intercept the Controller route handling lifecycle, and it provides a <code>OnProvidersExecuted()</code> method that is fired after routes have been auto-detected.</p>
<p>We can implement that method like this, to remove inherited routes:</p>
<pre><code class="language-csharp">namespace Westwind.AspNetCore;

/// &lt;summary&gt;
/// Runs after the full route table is built. Removes descriptors for base
/// controller actions when a subclass is also registered, eliminating the
/// ambiguous-route conflict (duplicate routes).
///
/// Register in Program.cs:
///   var convention = new InheritedControllerRouteConvention();
///   services.AddSingleton&amp;lt;IActionDescriptorProvider&amp;gt;(convention);
/// &lt;/summary&gt;
public class InheritedControllerRouteConvention :  IActionDescriptorProvider
{
 
    /// &lt;summary&gt;
    /// Optionally restrict which inherited concrete controller base types 
    /// we want to allow base class routes to work on.
    /// If empty, all inherited concrete controller base types are processed.    
    /// &lt;/summary&gt;
    public List&lt;Type&gt; ChildControllerTypes { get; set; } = [];

    public int Order =&gt; 0;
    public void OnProvidersExecuting(ActionDescriptorProviderContext context) { }

    /// &lt;summary&gt;
    /// This method finds all base controller types or those of the type(s)
    /// specified in &lt;see cref=&quot;ChildControllerTypes&quot;/&gt;
    /// and removes any [Route()] attributes on the child controllers
    /// to fix the duplication of routes that break inherited controller routing.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;context&quot;&gt;&lt;/param&gt;
    public void OnProvidersExecuted(ActionDescriptorProviderContext context)
    {
        var descriptors = context.Results
            .OfType&lt;ControllerActionDescriptor&gt;()
            .ToList();

        var controllerTypes = descriptors
            .Select(d =&gt; d.ControllerTypeInfo.AsType())
            .Distinct()
            .ToList();

        // Find child types to process (all, or the restricted list)
        var childTypes = ChildControllerTypes.Count &gt; 0
            ? controllerTypes.Where(t =&gt; ChildControllerTypes.Contains(t)).ToList()
            : controllerTypes;

        // Base types are those that a processed child inherits from and that are
        // also directly registered as controllers
        var baseTypesToSuppress = controllerTypes
            .Where(t =&gt; childTypes.Any(child =&gt; IsSubclassOf(child, t)))
            .ToList();

        var toRemove = descriptors
            .Where(d =&gt; baseTypesToSuppress.Any(bt =&gt; d.ControllerTypeInfo.AsType() == bt))
            .ToList();

        foreach (var d in toRemove)
            context.Results.Remove(d);
    }

    private static bool IsSubclassOf(Type child, Type parent) =&gt; child != parent &amp;&amp; parent.IsAssignableFrom(child);

}
</code></pre>
<p>This code looks at all the route descriptors captured, and then looks for our matching top level controllers (or all of them if not specified). It then finds all the routes defined on inherited types of the filtered list and removes them.</p>
<p>When running the code you end up with a set of routes to remove - in <strong>Figure 3</strong> the 7 routes are the base class routes in <code>QmmApiController</code> which is my filtered controller type that I specify.</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Getting-Inherited-Controller-Routes-to-work-and-ASP-NET-Core/RoutesToRemoveInStartupProcessing.png" alt="Routes To Remove In Startup Processing"><br>
<small><strong>Figure 3</strong> - Inherited routes to remove in the <code>IActionDescriptorProvider</code> processing </small></p>
<p>The code to hook this up in the ASP.NET startup code in <code>program.cs</code> looks like this:</p>
<pre><code class="language-csharp">var inheritedRouteConvention = new InheritedControllerRouteConvention
{
    ChildControllerTypes = [typeof(SampleAppQmmApiController)]
};
// Oddly this is what triggers the convention to be used!
services.AddSingleton&lt;IActionDescriptorProvider&gt;(inheritedRouteConvention);

var mvcBuilder = services.AddControllersWithViews()
    // the base controller comes from an external library
    .AddApplicationPart(typeof(QmmApiController).Assembly)
</code></pre>
<p>You can find this component and its functionality pre-built in the <a href="https://github.com/RickStrahl/Westwind.AspNetCore">Westwind.AspNetCore NuGet package</a>.</p>
<p><a href="https://amzn.to/4etxlQA"  target="_blank"
		  title="Sign up for an Amazon Visa - 5% cash back for Amazon and Whole Food Purchases">
<img src="https://weblog.west-wind.com/images/sponsors/AmazonPrimeVisa-Display.jpg" class="da-content-image" />
</a></p>
<h2 id="llm-heaven-and-hell">LLM Heaven and Hell?</h2>
<p>As you might imagine, this is the kind of thing where I engaged with LLMs - specifically with <a href="https://github.com/features/copilot">GitHub CoPilot</a> and <a href="https://github.com/features/copilot">Claude Code</a> with various models.</p>
<p>I say <strong>and with various models</strong> for a reason here, because in this case the LLMs really did an absolute shit job in a) trying to identify the problem correctly and b) providing a workable solution. So much so I switched between various tools and models several times, yet all of them came up with the same incorrect conclusion at first.</p>
<p>It took some extensive troubleshooting and <strong>Console.WriteLineing</strong> of routes and endpoints to properly diagnose the problem which was duplicate routes, not missing routes as the original LLM diagnoses was.</p>
<p>In the end, Claude Code (with Sonnet 4.6) ended up giving me a working solution but only after several very long troubleshooting loops and walking through spitting out route mappings and feeding them back into Claude and finally identifying that routes were duplicated.</p>
<p>Once the duplication issue was clearly established the final solution of the <code>IActionDescriptorProvider</code> class was adeptly created by Claude.</p>
<p>I will plainly admit that I probably <strong>would have not figured this out on my own</strong>. ASP.NET is powerful in the extensibility it has built in but discovering that flexibility is nearly impossible. You would think LLMs help here, but apparently at the edges in scenarios that haven't been widely published even the LLMs can end up not being a big help without some serious hands-on nudging.</p>
<blockquote>
<p>Getting this done was a real slog and many, many false solutions were tried along the way trying to solve the wrong problem.</p>
</blockquote>
<p>I continue to marvel at people who claim that they are one-shotting solutions and fixing problems - that never, ever seems to happen to me. I can massage an LLM into providing a solution most times, but it's never just a matter of one or even a few prompts - it's always try something and then re-direct the LLM after it's made bad assumptions. This gets very tricky in situations like this where I often don't have the expertise to check the validity of the assumptions so the only way to check is to go with it and figure it out as I go along and hope for the best...</p>
<p>But in the end, the LLM did provide a working solution, which on my own I likely would not have found.</p>
<p>As it is I spent way too much time on this 😄.</p>
<p><a href="https://goldenbeartshirts.com" target="_blank">
<img src="https://weblog.west-wind.com/images/sponsors/BearingDownTheMountain-DisplayAd.jpg" alt="Mountain Bike TShirt at Goldenbear T-Shirts" class="da-content-image" />
</a></p>
<h2 id="summary">Summary</h2>
<p>ASP.NET Controller route inheritance is not a thing you commonly do, but if you do find a use case for it, there are a number of things to watch out for.</p>
<p>Here are the main points summed up:</p>
<ul>
<li>Routes cannot be duplicated</li>
<li>Instance classes automatically publish their routes including in external libs if registered</li>
<li>Inherited instance Controller classes will cause route errors due to route duplication on the child class</li>
<li>Abstract Controller classes do not duplicate routes and can be safely subclassed with route inheritance</li>
<li>For inheriting instance Controller class you can use <code>IActionDescriptorProvider</code> to remove base class routes</li>
</ul>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="https://github.com/RickStrahl/Westwind.AspNetCore">Westwind.AspNetCore Library on GitHub</a></li>
</ul>
<div style="margin-top: 30px;font-size: 0.8em;
            border-top: 1px solid #eee;padding-top: 8px;">
    <img src="https://markdownmonster.west-wind.com/favicon.png" style="height: 20px;float: left; margin-right: 10px;">
    this post was created and published with the 
    <a href="https://markdownmonster.west-wind.com" target="top">Markdown Monster Editor</a> 
</div>
]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Jun/30/Getting-Inherited-Controller-Routes-to-work-in-ASPNET-Core</link>
      <guid isPermaLink="false">jq09wrhriyz8</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Jun/30/Getting-Inherited-Controller-Routes-to-work-in-ASPNET-Core#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Jun/30/Getting-Inherited-Controller-Routes-to-work-in-ASPNET-Core</guid>
      <pubDate>Tue, 30 Jun 2026 00:00:00 GMT</pubDate>
      <abstract><![CDATA[Controller inheritance in ASP.NET Core is an edge case, but if you need it you have to be mindful of how route inheritance works in ASP.NET.  This post explores why concrete class inheritance causes route duplication and provides a couple of solutions.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/imageContent/2026/Getting-Inherited-Controller-Routes-to-work-and-ASP-NET-Core/Banner.jpg</featuredImage>
    </item>
    <item>
      <title>Creating Dual Use Windows GUI and Console Applications</title>
      <description><![CDATA[<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/GuiConsoleAppBanner.jpg" alt="Gui Console App Banner"></p>
<p>In <a href="https://weblog.west-wind.com/posts/2026/Jun/13/Creating-a-Packaged-Single-File-Web-Site-Viewer-Executable">my last post</a> I described a <a href="https://github.com/RickStrahl/WebPackageViewer">WebPackageViewer tool</a> tool that acts as a static Web site packager and self-contained Web site viewer all contained in a single Executable.</p>
<p>One feature of this single file tool is that it acts both as a GUI application (the Web site viewer) and as a CLI application (the package/unpackage tooling) from a single EXE. However, using both GUI and CLI interface from a single EXE is challenging and doesn't have a 100% clean solution. In this post I'll describe several options that make this dual mode operation work with an <strong>as clean as possible</strong> approach, as well as some alternatives that I've used in other applications.</p>
<p>If you think this is an off the wall concept, all of my commercial desktop applications <a href="https://markdownmonster.west-wind.com">Markdown Monster</a>, <a href="https://websurge.west-wind.com">WebSurge</a> and <a href="https://documentationmonster.com">Documentation Monster</a> have a support CLI for exposing common functionality in a scriptable way. But... in all of these latter cases I actually chose a different approach of using separate EXEs for the GUI app and CLI app with the CLI app driving the GUI app features. It's a very different use case than the simple single Exe WebPackager tool and it works well for full fledged applications that expose a CLI.</p>
<h2 id="cli-interfaces">CLI Interfaces</h2>
<p>In this post I'll discuss 3 different approaches. None of them are what I would consider perfect, which would be if Windows simply supported some way to cleanly service both GUI and Console apps from a single Exe.</p>
<p>But alas, it's Windows so we have to live with trade-offs. Here are the three I'll discuss:</p>
<ul>
<li>Create a GUI application with a Console interface</li>
<li>Create a Console Application and launch GUI from Console</li>
<li>Create separate CLI and GUI applications with shared functionality</li>
</ul>
<p>I've used all of these approaches now at some point or another, and it depends on the type of application or tool that you're building which makes the most sense.</p>
<p><a href="https://markdownmonster.west-wind.com?ut=weblog"  target="_blank"
	  title="Markdown Monster - Easy to use, yet powerfully productive Markdown Editing for Windows">
<img src="https://weblog.west-wind.com/images/sponsors/MarkdownMonster-Display2.jpg" class="da-content-image" />
</a></p>
<h3 id="gui-application-with-cli-interface-option">GUI Application with CLI Interface Option</h3>
<p>Mixed mode GUI app that also supports CLI output is the most tricky of these approaches, because Windows makes this sort of thing difficult with <strong>choose-one-or-the-other</strong> situation. It's also the most likely situation you're going to find yourself in when you build a GUI app and then later decide that it would be nice to add some CLI functionality.</p>
<p>When you build a Windows .NET application (or any Windows application for that matter) you havet to specify whether it's a <code>WinExe</code> (GUI) or <code>Exe</code> (Console) application. The type of app is written into the PE header when the EXE is created.</p>
<p>In .NET you can specify this in the project's header:</p>
<pre><code class="language-xml">&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
	&lt;PropertyGroup&gt;
		&lt;!-- Windows GUI app - Exe for Console --&gt;
		&lt;OutputType&gt;WinExe&lt;/OutputType&gt;
		
		&lt;TargetFramework&gt;net472&lt;/TargetFramework&gt;
		&lt;UseWPF&gt;true&lt;/UseWPF&gt;
		&lt;Version&gt;1.1.5.2&lt;/Version&gt;
</code></pre>
<p>This affects the <strong>SubSystem</strong> value of the Windows PE header that gets generated into Windows Exes:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/ConsoleGuiPeHeader.jpg" alt="Console Gui Pe Header">
<small><strong>Figure 1</strong> - GUI and Console apps have different startup semantics in how they related to Consoles that are attached or loaded based on the SubSystem value in the PE header.</small></p>
<p>When you launch as a Console application a new Console is started if none is active. That's when you invoke via the Windows shell or Explorer. If launched from an existing Console in the Terminal the Console app attaches to the existing Console and pipes output into it including all the Console streams (Input/Output/Error).</p>
<p>When you launch a GUI app from the shell, no Console is launched, so by default there's no Console - the Console points at a null console if you write to it and that output goes nowhere.</p>
<p>Where it gets weird is if you launch a GUI app from a Console, and you then write to the console which is the exact scenario that I'm using in <strong>WebPackageViewer</strong>.</p>
<p>By default the launching Console and the GUI exe are not connected and so by default Console input and output are still not going anywhere. However, it's possible to attach to an existing Console using  a native <code>AttachConsole()</code> call from a GUI application when the application starts up, which effectively allows your GUI application to send Console output and input to and from the console.</p>
<p>You can use the following two P/Invoke calls (on Windows) to attach and release the Console:</p>
<pre><code class="language-cs">[DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
static extern bool FreeConsole();

[DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
static extern bool AttachConsole(int dwProcessId);
</code></pre>
<p>Then as part of your application's startup code you can attach the Console:</p>
<pre><code class="language-csharp">protected override void OnStartup(StartupEventArgs e)
{
    bool attached = AttachConsole(-1);  // -1 - active console
    ...
     
    if (attached)
		Console.Write(&quot;\n✅ Launching Web Viewer...&quot;);
	
	...
	
	// when done
	if(attached)
		FreeConsole();
</code></pre>
<p>This sorta works.</p>
<p>The problem is that Console output goes into the active console that the application was started from, but if the application runs for any sort of duration, the console output gets mixed up with the existing prompt:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/ConsoleFail.png" alt="Console Fail"><br>
<small><strong>Figure 2</strong> - Console Fail - In a GUI Application you can attach to a console, but the output gets very janky and the Console doesn't always return to the prompt after completion</small></p>
<p>The reason for this is that a console launched GUI application <strong>returns almost immediately to the console</strong> while the GUI app continues running in the background. The end result is that you get a new prompt that appears to be mixed into your Console output.</p>
<p>Depending on where the prompt occurs, it looks like the existing console's prompt is now overwriting your  content, but really the prompt is left behind while your output continued into no-man's land. It displays but no longer related to the now active prompt.</p>
<p>Furthermore, once the native prompt has completed if you call <code>FreeConsole()</code> the console has now <em>lost the prompt</em> and essentially hangs until you press a key. While it looks like the prompt is lost, what's really happening is that the cursor appears to be at the end of the output, but the actual prompt is the prompt above in the middle of the Console output.</p>
<p>Yeah, it's bloody mess!</p>
<p>To fix this somewhat I use a helper to release the console rather than just calling <code>FreeConsole()</code>:</p>
<pre><code class="language-csharp">[DllImport(&quot;user32.dll&quot;)] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, nuint dwExtraInfo);

const byte VK_RETURN = 0x0D;

static void ReleaseConsolePrompt()
{
    Console.WriteLine();  // force another line break so that the prompt is on a new line
    FreeConsole();
    
    // force a CR into the console
    keybd_event(VK_RETURN, 0, 0, 0);         // key down
    keybd_event(VK_RETURN, 0, 0x0002, 0);    // key up (KEYEVENTF_KEYUP)
}
</code></pre>
<p>which ends up showing a new prompt at the bottom with the cursor at the active new prompt!</p>
<h4 id="can-you-live-with-it">Can you live with it?</h4>
<p>In a pinch, this sort of funky output works for internal applications where you have a very short output, but for a commercial tool or something that has a lot of output that takes a bit to run, that's not really an option as it just looks like shit.</p>
<p>What's annoying is that the behavior of the prompt can vary. I can run the same command multiple times and sometimes it'll get interrupted by the prompt, sometimes not. If your app's CLI commands run very fast within a few milliseconds you can preempt the console prompt interference. If it's very slow you can be sure it'll show up in an unexpected location.</p>
<p>For some applications that only occasionally use the CLI or that are driven via automation this may not matter and is acceptable. It's the easiest path of providing a CLI interface to a GUI application and may just be <strong>Good Enough</strong>.</p>
<h4 id="hackery">Hackery!</h4>
<p>For slight performance trade off you can make this a little better by essentially <strong>forcing the Console to show the new prompt immediately</strong> by waiting for a brief period with <code>Thread.Sleep()</code>. The idle cycle in the app makes the Console show a new, second prompt immediately.</p>
<p>The idea is that you preemptively force the Console to show a new prompt so it doesn't overwrite your Console output in the middle of your content.</p>
<p>So in <code>WebPackageViewer</code> I do this:</p>
<pre><code class="language-csharp">protected override void OnStartup(StartupEventArgs e)
{            
    IsConsoleApp =  AttachConsole(-1);
    if (IsConsoleApp)
    {
        // delay slightly to let existing prompt finish and then show our prompt
        System.Threading.Thread.Sleep(20);
        
        // Insert a line to clear the &gt; prompt
        Console.WriteLine();
    }
</code></pre>
<p>Here's what that looks like in PowerShell with a custom OhMyPosh prompt:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/HackedGuiConsole.png" alt="Hacked Gui Console"><br>
<small><strong>Figure 3</strong> - A GUI app with Console output that delays slightly to force the completing existing Console prompt to display immediately, which avoids overwriting our Console output.</small></p>
<p>Here's what it looks like in a plain Command prompt:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/HackedGuiConsoleCommand.png" alt="Hacked Gui Console Command"><br>
<small><strong>Figure 4</strong> - Plain Command Prompt with the same delayed Console display. </small></p>
<p>If you look close you see the original Console prompt finish, and <strong>then</strong> our actual Console output is displayed. I added an extra <code>Console.WriteLine()</code> into the code to skip down over the prompt line (<code>&gt;</code>).</p>
<p>Is that perfect? No, but it looks a lot cleaner than having the prompt injected in the middle, or weird line breaks showing up in your Console output. While we still can't avoid the extra prompt, at least now it's in a predictable location at the very top where it's not interfering with our Console content. And if you don't pay close attention you may not even notice that it's happening... 😉</p>
<p>If you want to see this all working together you can take a look in <a href="https://github.com/RickStrahl/WebPackageViewer"><code>App.xaml.cs</code> in the  WebPackageViewer project</a>.</p>
<h4 id="is-console-interface-important">Is Console Interface Important?</h4>
<p>When building CLI tools, the use case is often about automation. For many CLI tools actual Console interaction may be rare anyway because the primary use case is automation.</p>
<p>For example, in Documentation Monster (a desktop application) I automate <code>WebPackageViewer</code> from the application via <code>Process.Start()</code>. I generate the Html Output in the application, package up the files explicitly into a Zip file, then use the packager to package the single file Exe. No Console interface accessed. I'm using the CLI interface, but I'm not ever actually looking at the Console so the output is not important - only the exit code.</p>
<p>In the end having a Console that doesn't behave 100% correctly may not be a big deal, especially when you can get it close enough as described above.</p>
<h4 id="when-to-use-this">When to use this</h4>
<p>If the primary application you are creating is a GUI app and the CLI functionality is secondary, then this approach can work very well for you.</p>
<p>For my use case in <code>WebPackageViewer</code> I used this approach as it was the best choice for this utility for the following reasons:</p>
<ul>
<li>I <strong>absolutely</strong> need a single Executable</li>
<li>The GUI interface is the primary feature users see</li>
<li>The CLI interface is likely  automated and not actually visibly running from the command line</li>
<li>The CLI output works well enough with the embellishments described in this post</li>
</ul>
<p>This integration ticks all of these points and the only real downside is the slightly messy CLI interface with the duplicated prompt line. I can live with that! In this case.</p>
<p><a href="https://amzn.to/3SI8Whs"  target="_blank"
		  title="Broken Money - A Comprehensive Overview of the Past, Present, and Future of Money">
<img src="https://weblog.west-wind.com/images/sponsors/BrokenMoney-Display.jpg" class="da-content-image" />
</a></p>
<h3 id="console-application-that-hosts-a-gui-interface">Console Application that hosts a GUI Interface</h3>
<p>As I've described above it's possible to create a GUI app that can interact with the Console, but you can also create the reverse: A Console application that can run a GUI application.</p>
<p>This might seem counter-intuitive and most likely this will come up <strong>after</strong> you've decided to build the entire application as a GUI app - as it did for me!</p>
<p>Realistically though the differences between a Windows GUI and Console application are relatively minor from an implementation perspective. Even for a WPF application it's possible to switch with a few lines of code. It comes down to specifying the Windows Subsystem used during build time and changing the startup code.</p>
<p>For .NET projects this means changing to <code>&lt;OutputType&gt;Exe&lt;/OutputType&gt;</code>. The following is from the <code>WebPackageViewer</code> which deliberately builds a .NET Framework Executable to remove any runtime requirements so it works on any recent Windows machine:</p>
<pre><code class="language-xml">&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
	&lt;PropertyGroup&gt;
		&lt;!-- Exe: Console - WinExe: GUI --&gt;
		&lt;OutputType&gt;Exe&lt;/OutputType&gt;
		&lt;TargetFramework&gt;net472&lt;/TargetFramework&gt;
		&lt;UseWPF&gt;true&lt;/UseWPF&gt;
		...
	&lt;/PropertyGroup&gt;		
&lt;/Project&gt;	
</code></pre>
<blockquote>
<p>If you're using ILMerge or ILRepack to package a single file binary, the final EXE and its PE Header is actually determined by those tools, not your project. In ILRepack this is the <code>/target:exe</code> or <code>/target:winexe</code> parameter. This means if you use these tools, it doesn't matter what you set for <code>&lt;OutputType&gt;</code> in the .NET project as the assignment overrides that value in ILMerge/ILRepack scripting!</p>
</blockquote>
<p>The other thing that has to change is that a Console application has to start with a <code>static int Main()</code> method, so <strong>you have to</strong> explicitly add this to your application, in this case for a WPF application that initializes and runs <code>app.xaml</code>:</p>
<pre><code class="language-csharp">using System;
using System.IO;
using System.Runtime.InteropServices;
using WebPackageViewer;

class Program
{
    [STAThread]
    static int Main(string[] args)
    {
        var app = new App();
        app.InitializeComponent();
        app.Run();

        return 0;
    }
}
</code></pre>
<p>and you should explicitly specify the startup class in the <code>.csproj</code> file:</p>
<pre><code class="language-xml">&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
	&lt;PropertyGroup&gt;
		&lt;StartupObject&gt;Program&lt;/StartupObject&gt;
	&lt;/PropertyGroup&gt;
&lt;/Project&gt;
</code></pre>
<p>Incidentally this also works for GUI mode applications and in fact I launch all of my GUI apps this way as I generally have a few startup checks that I include before the app actually gets launched. Also a great location for a launch screen that pops quicker here than in XAML code for WPF, WinForms or WinUi frameworks startup.</p>
<p>If you go this route, you don't need to <code>AttachConsole()</code> and <code>FreeConsole()</code>. Any Console commands work as you'd expect including having all the Console Streams hooked up.</p>
<h4 id="whats-the-downside-of-a-console-gui-application">What's the Downside of a Console GUI Application?</h4>
<p>Unfortunately, there is one downside to a Console application that doubles as a GUI application: A Console compiled application <strong>always</strong> displays a Console window and there's no good way to <strong>completely</strong> hide the window when the app starts up.</p>
<p>You can hide the Console window immediately after startup using code like this:</p>
<pre><code class="language-csharp">class Program
{
    [STAThread]
    static int Main(string[] args)
    {         
        if (!StartedFromConsole())
        {
            // hide the Console window immediately
            ShowWindow(GetConsoleWindow(), 0); // hide console flash
        }

        var app = new App();
        app.InitializeComponent();
        app.Run();

        return 0;
    }

    [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]
    static extern bool AttachConsole(int dwProcessId);

    [DllImport(&quot;kernel32.dll&quot;)]
    static extern bool FreeConsole();

    [DllImport(&quot;kernel32.dll&quot;)] static extern IntPtr GetConsoleWindow();
    [DllImport(&quot;user32.dll&quot;)] static extern bool ShowWindow(IntPtr h, int cmd);


    static bool StartedFromConsole()
    {
        if (AttachConsole(-1))
        {
            FreeConsole();
            return true;
        }

        // Already attached to a console also means console-launched.
        return Marshal.GetLastWin32Error() == 5;
    }
}
</code></pre>
<p>But even with this code at the very earliest possible point of .NET code entry, you'll get a brief flash or worse a slow animation of the Console Window disappearing.</p>
<p>The code above is also a bit simplistic as it universally hides the Console window. In reality you want to hide it selectively only when you're actually going to display UI, and leave it when you're working with the Console, which may cause you to delay the hiding a little bit longer yet, making the window flash even more pronounced.</p>
<p>In WebPackageViewer when I was experimenting with this, I ended up sticking the window hiding right before the Main Window of the Viewer is created:</p>
<pre><code class="language-csharp">// code in OnStartup that handles CommandLine Parsing and execution
// and UI operations

// check and hide only before actual GUI operation
if (!StartedFromConsole())
{
    // hide the Console window immediately
    ShowWindow(GetConsoleWindow(), 0); // hide console flash
}

MainWindow mainWindow = new MainWindow(config);
mainWindow.Show();
</code></pre>
<p>But even that may not be quite the right behavior because if you actually launch the UI application from the Console explicitly via keyboard, then you'd want the Console to stay active. There's no easy way to determine whether the Console was created by your application or an existing console in a Console app because a Console is always present.</p>
<h4 id="when-to-use-this-1">When to use this</h4>
<p>Functionally, a Console application with a GUI interface ticks all the boxes and gives you the best of both Console and GUI applications, except for the initial Console Window popup.</p>
<p>If you can live with the Console popup and it isn't a distraction to you, or if your app is primarily a Console interface, then using a Console app is the way to go.</p>
<p>But for me personally, I find the brief Console popup annoying and unprofessional for a GUI app, so other than for applications that are entirely CLI driven and use GUI only as adjunct, I would probably not opt for this choice.</p>
<h3 id="separate-cli-application">Separate CLI Application</h3>
<p>Another option for creating both a GUI and Console interface is to create two completely separate applications. As I've shown above both GUI app with CLI and CLI with GUI apps have quirks that make them behave not quite right for the CLI or UI scenario.</p>
<h4 id="avoiding-ambiguities">Avoiding Ambiguities</h4>
<p>By separating out the GUI and CLI into completely separate applications you can avoid any of these ambiguities by giving each it's dedicated target Subsystem type.</p>
<p>This works particularly well if your CLI interface is fairly sophisticated and requires the full Console experience including the ability to be driven through Console IO.</p>
<p>I'm using this approach of two separate EXE interface in Markdown Monster, WebSurge and Documentation Monster and it's a relatively simple set up in that the CLI project can simply import the GUI project (or 'business' project) as a reference and get all of the same functionality as the main GUI app without the overhead of all library requirements because it uses the same libraries as the main app.</p>
<h4 id="how-does-this-work">How does this work?</h4>
<p>So, using the <a href="https://markdownmonster.west-wind.com/docs/Startup-and-Command-Line-Options/Command-Line-Operations.html">Markdown Monster CLI Example</a> I have two .NET projects:</p>
<ul>
<li>MarkdownMonster <small><em>(GUI WPF app)</em></small></li>
<li>mmcli  <small><em>(Console App)</em></small></li>
</ul>
<p><code>mmcli</code> references <code>MarkdownMonster</code> which is a single assembly monolith. <code>mmcli</code> then calls into the <code>MarkdownMonster</code> and its internal libraries to use all of the built in operational logic to handle many system operations related to installation,  generate html and pdf output, start and stop the internal Web server and so on. In MM it's a single monolith that contains most of the logic, but in other tools like WebSurge, a separate business library that contains most of these operations is referenced. In either case, the CLI project references the 'parent' application's libraries that are effectively shared between both projects.</p>
<p>Here's an example of Markdown Monster's CLI generating Html output from Markdown:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/ConsoleOutputMarkdownMonsterCLI.jpg" alt="Console Output Markdown Monster CLI"><br>
<small><strong>Figure 5</strong> - Using the separate <code>mmCli</code> Console application in Markdown Monster to generate various types of Html output </small></p>
<p>In the project the setup looks something like this:</p>
<p><img src="https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/MarkdownMonsterAndCLIProjectSetup.png" alt="Markdown Monster And CLI Project Setup"><br>
<small><strong>Figure 6</strong> - GUI and CLI projects are separate, with the small CLI project importing all operational functionality from the GUI project (or libraries)</small></p>
<h4 id="cli-projects-can-have-small-footprint">CLI Projects can have small Footprint</h4>
<p>The bottom line here is that the CLI project itself is very small and only implements the command line parsing + the logic to drive the application logic to perform the operations that are defined in the main application code base (either the main EXE or some business library). When the project builds, only the CLI executables (.exe and .dll + the runtime config files) are copied into the main GUI executable's folder:</p>
<pre><code class="language-xml">&lt;Target Name=&quot;PostBuild&quot; AfterTargets=&quot;PostBuildEvent&quot;&gt;
  &lt;Exec Command=&quot;copy $(TargetDir)mmcli.exe $(SolutionDir)MarkdownMonster\mmcli.exe&quot; /&gt;
  &lt;Exec Command=&quot;copy $(TargetDir)mmcli.dll $(SolutionDir)MarkdownMonster\mmcli.dll&quot; /&gt;
  &lt;Exec Command=&quot;copy $(TargetDir)mmcli.runtimeconfig.json $(SolutionDir)MarkdownMonster\mmcli.runtimeconfig.json&quot; /&gt;
  &lt;Exec Command=&quot;copy $(TargetDir)mmcli.deps.json $(SolutionDir)MarkdownMonster\mmcli.deps.json&quot; /&gt;
&lt;/Target&gt;
</code></pre>
<p>Because both projects share the exact same dependencies, the footprint of the CLI project is tiny - just the <code>.exe</code> and <code>.dll</code> file even though the CLI project's build output is huge - roughly the same as the main GUI project. So by simply copying the binaries into the main project folder, the CLI binaries have access to everything they need and can run just fine.</p>
<h4 id="when-to-use">When to use</h4>
<p>If you can live with multiple executables, separate CLI and GUI projects are the cleanest solution for dual interface applications. Each application can run in its intended environment without any hacks and workarounds.</p>
<p>The only downside is that it takes a little extra effort to set up two separate projects and ensure that the two binaries and runtime config files are available in the right places.</p>
<p><a href="https://goldenbeartshirts.com"  target="_blank"
	  title="Pickleballs and Bears">
<img src="https://weblog.west-wind.com/images/Sponsors/PickleBallBearTshirt-Display.jpg" class="da-content-image" alt="Pickleball Bear TShirt at Goldenbear T-Shirts"/>
</a></p>
<h2 id="summary">Summary</h2>
<p>Mixed mode GUI and CLI applications are not very common. Most applications stick to a simple single interface and use that. GUI applications that have some command line switches typically don't use Console interfaces to display output but rather rely on GUI prompts or forms to display information, so those typically are not dual interface either.</p>
<p>But when you have true dual purpose use cases like I did with <code>WebPackageViewer</code> then a dual interface can be quite useful to provide both a nice GUI interface and a CLI to drive it.</p>
<p>In this post I've described various ways you can create dual interface GUI and CLI applications:</p>
<p><strong>1. GUI App with Console Interaction</strong></p>
<ul>
<li>use for UI primary application (ie. a Viewer)</li>
<li>easy to build</li>
<li><code>AttachConsole()</code> and <code>FreeConsole()</code></li>
<li>CLI is least desirable but works for 'quick and dirty use'</li>
</ul>
<p><strong>2. Console Application that Launches a GUI</strong></p>
<ul>
<li>use for Console centric applications that also have UI</li>
<li>requires <code>program.cs</code> launch for GUI (ie. a little non-standard)</li>
<li>easy to build but need to isolate GUI from Console commandlines</li>
<li>for GUI apps shows or at least flashes the Terminal Window</li>
</ul>
<p><strong>3. Separate GUI and CLI Application</strong></p>
<ul>
<li>two Separate Exes</li>
<li>no 'routing' required</li>
<li>Separates concerns</li>
<li>CLI can link in GUI app or library features</li>
<li>no UI oddities for either GUI and CLI</li>
</ul>
<p>For <code>WebPackageViewer</code> I opted for a GUI app as the Viewer is the primary interface that end-users see, and because the CLI automation most likely won't actually be done via a Console but through some sort of automation. Specifically in my case through I use a separate application. In that project the main reason is because of the single file requirement, so I had to choose between option 1 and 2, with 1 winning out because of the primarily GUI focus of the tool.</p>
<p>For most of my other much bigger application products I've chosen to use separate CLI and GUI projects because it's simply cleaner to separate out the CLI functionality into a separate binary. There are multiple reasons for this. For example, Markdown Monster already has a native command line interface that allows it to open files in various different ways, deal with single-instance limiting and other command line options that deal with application startup. In other words it already has a bunch of command line processing it has to do in various different modes. Adding CLI commands to that would actually be quite complicated. WebSurge and DocMonster have simpler command lines but there are still options to deal with and having separated, well-delineated CLI syntax is much easier to implement and also to use for users without ambiguities.</p>
<p>Beyond maintaining a separate project and setting up the initial build process to produce the binaries in the right place, there's virtually no downside to using separate projects as I get full access to all the functionality of the main application in the CLI project, with the clean separation of functionality. To me if this option is available, it's clearly the cleanest approach.</p>
<p>That leaves the Console Application with GUI launching (2), and although I was initially excited about it, the fact that the Console window pops up in GUI operation is major showstopper for me. If it weren't for that I think I would consider building every application using a Console application. It sure would be nice if Microsoft provided a way to initially hide the Console window on launch via a Manifest setting or something, but AFAIK no such thing exists - the best you can do is hide the window immediately and deal with the brief Console flash. For some situations that may not be a problem, but for me that's a non-starter. YMMV.</p>
<p><code>WebPackageViewer</code> was an interesting experiment in that it forced me to explore several of these approaches and try to make them work 'perfectly'. In the end I managed to get several 'good enough' approaches to work, with the only near perfect solution being separate EXEs.</p>
<p>Ah, good enough 😂</p>
<div style="margin-top: 30px;font-size: 0.8em;
            border-top: 1px solid #eee;padding-top: 8px;">
    <img src="https://markdownmonster.west-wind.com/favicon.png" style="height: 20px;float: left; margin-right: 10px;">
    this post was created and published with the 
    <a href="https://markdownmonster.west-wind.com" target="top">Markdown Monster Editor</a> 
</div>
]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Jun/23/Creating-Dual-Use-Windows-GUI-and-Console-Applications</link>
      <guid isPermaLink="false">27v1kvj96o5y</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Jun/23/Creating-Dual-Use-Windows-GUI-and-Console-Applications#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Jun/23/Creating-Dual-Use-Windows-GUI-and-Console-Applications</guid>
      <pubDate>Tue, 23 Jun 2026 00:00:00 GMT</pubDate>
      <abstract><![CDATA[Building a tool that provides both a rich Windows GUI and a functional CLI from a single executable presents unique challenges due to how Windows handles subsystem types. This post explores three approaches for dual-mode apps: attaching to consoles from a GUI, launching UIs from a console app, and creating separate specialized EXEs. I’ll share the "clean as possible" workarounds for console jank and window flashing used in my own production tools.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/imageContent/2026/Creating-a-Windows-GUI-App-that-also-Doubles-as-a-CLI-App/GuiConsoleAppBanner.jpg</featuredImage>
    </item>
    <item>
      <title>Creating a Packaged Windows Single File Web Site Viewer Executable</title>
      <description><![CDATA[In this post I discuss how a self-contained Web Site Viewing tool using a single Windows executable that that packages and runs an entire website locally. I discuss the use case and implementation of creating a self-contained Windows executable that can be generated to contain both the executable itself and the data - in this case a zipped up Web site - to use. ]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Jun/13/Creating-a-Packaged-Single-File-Web-Site-Viewer-Executable</link>
      <guid isPermaLink="false">v7x3mwmnhs55</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Jun/13/Creating-a-Packaged-Single-File-Web-Site-Viewer-Executable#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Jun/13/Creating-a-Packaged-Single-File-Web-Site-Viewer-Executable</guid>
      <pubDate>Sat, 13 Jun 2026 00:00:00 GMT</pubDate>
      <abstract><![CDATA[In this post I discuss how a self-contained Web Site Viewing tool using a single Windows executable that that packages and runs an entire website locally. I discuss the use case and implementation of creating a self-contained Windows executable that can be generated to contain both the executable itself and the data - in this case a zipped up Web site - to use. ]]></abstract>
      <featuredImage>https://weblog.west-wind.com/imageContent/2026/Creating-a-Packaged-Single-File-Web-Site-Viewer-Executable/Banner.jpg</featuredImage>
    </item>
    <item>
      <title>Lost ASP.NET Identity Cookies on IIS Application Pool Restarts</title>
      <description><![CDATA[If you find that your ASP.NET authentication cookies expire every time your IIS application pool restarts or recycles, the culprit is likely the DataProtection API not finding the previously stored keys.  This post describes one gotcha I ran into with the default storage location on IIS in the user profile due to a default Application Pool setting.]]></description>
      <link>https://weblog.west-wind.com/posts/2026/May/31/Lost-ASPNET-Cookies-on-IIS-Restarts</link>
      <guid isPermaLink="false">yd1j66azcyja</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/May/31/Lost-ASPNET-Cookies-on-IIS-Restarts#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/May/31/Lost-ASPNET-Cookies-on-IIS-Restarts</guid>
      <pubDate>Sun, 31 May 2026 08:49:58 GMT</pubDate>
      <abstract><![CDATA[If you find that your ASP.NET authentication cookies expire every time your IIS application pool restarts or recycles, the culprit is likely the DataProtection API not finding the previously stored keys.  This post describes one gotcha I ran into with the default storage location on IIS in the user profile due to a default Application Pool setting.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/imageContent/2026/Lost-ASP-NET-Cookies-on-IIS-Restarts/CookieMonsterAttackOnIis.jpg</featuredImage>
    </item>
    <item>
      <title>Running ASP.NET Core Applications as a Subfolder Application</title>
      <description><![CDATA[While ASP.NET Core applications typically run from the root folder, some scenarios—such as hosting multiple blogs under a single domain—require running from a subfolder. This post explains how to configure ASP.NET Core with app.UsePathBase() for proper routing and ~/ path resolution, along with the IIS setup required for a dedicated Application Pool using "No Managed Code." It also covers key migration tips, including bulk updates for root-relative links and JavaScript adjustments to keep client-side functionality working in a subfolder environment.]]></description>
      <link>https://weblog.west-wind.com/posts/2026/May/26/Running-ASPNET-Core-Applications-in-an-IIS-Subfolder-Application</link>
      <guid isPermaLink="false">qzzxfojpce9j</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/May/26/Running-ASPNET-Core-Applications-in-an-IIS-Subfolder-Application#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/May/26/Running-ASPNET-Core-Applications-in-an-IIS-Subfolder-Application</guid>
      <pubDate>Tue, 26 May 2026 14:16:20 GMT</pubDate>
      <abstract><![CDATA[While ASP.NET Core applications typically run from the root folder, some scenarios—such as hosting multiple blogs under a single domain—require running from a subfolder. This post explains how to configure ASP.NET Core with app.UsePathBase() for proper routing and ~/ path resolution, along with the IIS setup required for a dedicated Application Pool using "No Managed Code." It also covers key migration tips, including bulk updates for root-relative links and JavaScript adjustments to keep client-side functionality working in a subfolder environment.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/imageContent/2026/Running-ASP-NET-Core-Applications-in-an-IIS-Subfolder-Application/PostBanner.jpg</featuredImage>
    </item>
    <item>
      <title>Getting the Client IP Address in ASP.NET Core</title>
      <description><![CDATA[When I need to pick up the client IP Address in ASP.NET Core I always forget where to find the connection information and/or forget about picking proxy forwarding instead of the actual IP address. To make things easy and reusable, here's a small HttpRequest extension method.]]></description>
      <link>https://weblog.west-wind.com/posts/2026/May/13/Getting-the-Client-IP-Address-in-ASPNET-Core</link>
      <guid isPermaLink="false">dkvnwxdbh42n</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/May/13/Getting-the-Client-IP-Address-in-ASPNET-Core#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/May/13/Getting-the-Client-IP-Address-in-ASPNET-Core</guid>
      <pubDate>Wed, 13 May 2026 10:35:26 GMT</pubDate>
      <abstract><![CDATA[When I need to pick up the client IP Address in ASP.NET Core I always forget where to find the connection information and/or forget about picking proxy forwarding instead of the actual IP address. To make things easy and reusable, here's a small HttpRequest extension method.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/images/2026/Getting-the-Client-IP-Address-in-ASP-NET-Core/ClientIpBanner.jpg</featuredImage>
    </item>
    <item>
      <title>Putting the Westwind.Scripting C# Templating Library to work, Part 2</title>
      <description><![CDATA[In part 2 of this post series I look at some of the issues you may have to deal with when using the Westwind.Scripting library as an offline document or Web site creation engine. While running simple templates is easy enough, when generating static output for Web site publishing or local preview requires some special considerations.]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Apr/23/Putting-the-WestwindScripting-Templating-Library-to-work-Part-2</link>
      <guid isPermaLink="false">5314605</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Apr/23/Putting-the-WestwindScripting-Templating-Library-to-work-Part-2#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Apr/23/Putting-the-WestwindScripting-Templating-Library-to-work-Part-2</guid>
      <pubDate>Thu, 23 Apr 2026 00:00:00 GMT</pubDate>
      <abstract><![CDATA[In part 2 of this post series I look at some of the issues you may have to deal with when using the Westwind.Scripting library as an offline document or Web site creation engine. While running simple templates is easy enough, when generating static output for Web site publishing or local preview requires some special considerations.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/images/2026/Revisiting-C-Scripting-with-the-Westwind-Scripting-Templating-Library,-Part-1/Part2-Banner.jpg</featuredImage>
    </item>
    <item>
      <title>Revisiting C# Scripting with the Westwind.Scripting Templating Library, Part 1</title>
      <description><![CDATA[The `Westwind.Scripting` library provides runtime C# code compilation and execution as well as a C# based Script Template engine using Handlebars style syntax with pure C# code. In this post I discuss use cases for script templating and some examples of how I use in real-world applications, followed by a discussion of the engine's features and the new Layout, Section and Partials feature that was added recently.]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Apr/01/Revisiting-C-Scripting-with-the-WestwindScripting-Templating-Library-Part-1</link>
      <guid isPermaLink="false">5311031</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Apr/01/Revisiting-C-Scripting-with-the-WestwindScripting-Templating-Library-Part-1#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Apr/01/Revisiting-C-Scripting-with-the-WestwindScripting-Templating-Library-Part-1</guid>
      <pubDate>Wed, 01 Apr 2026 00:00:00 GMT</pubDate>
      <abstract><![CDATA[The `Westwind.Scripting` library provides runtime C# code compilation and execution as well as a C# based Script Template engine using Handlebars style syntax with pure C# code. In this post I discuss use cases for script templating and some examples of how I use in real-world applications, followed by a discussion of the engine's features and the new Layout, Section and Partials feature that was added recently.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/images/2026/Revisiting-C-Scripting-with-the-Westwind-Scripting-Templating-Library,-Part-1/Scripting-Banner.jpg</featuredImage>
    </item>
    <item>
      <title>Using .NET Native AOT to build Windows WinAPI Dlls</title>
      <description><![CDATA[Did you know that you can use .NET AOT compilation to create native Windows DLLs to potentially replace traditional C/C++ compiled DLLs? It's now possible to build completely native DLLs that can be called from external applications and legacy applications in particular using .NET AOT  compilation. In this post I show how this works and discuss the hits and misses of this tech.]]></description>
      <link>https://weblog.west-wind.com/posts/2026/Mar/21/Using-NET-Native-AOT-to-build-Windows-WinAPI-Dlls</link>
      <guid isPermaLink="false">5321191</guid>
      <author> (Rick Strahl)</author>
      <comments>https://weblog.west-wind.com/posts/2026/Mar/21/Using-NET-Native-AOT-to-build-Windows-WinAPI-Dlls#Comments</comments>
      <guid>https://weblog.west-wind.com/posts/2026/Mar/21/Using-NET-Native-AOT-to-build-Windows-WinAPI-Dlls</guid>
      <pubDate>Sat, 21 Mar 2026 11:47:13 GMT</pubDate>
      <abstract><![CDATA[Did you know that you can use .NET AOT compilation to create native Windows DLLs to potentially replace traditional C/C++ compiled DLLs? It's now possible to build completely native DLLs that can be called from external applications and legacy applications in particular using .NET AOT  compilation. In this post I show how this works and discuss the hits and misses of this tech.]]></abstract>
      <featuredImage>https://weblog.west-wind.com/images/2026/Using-NET-Native-AOT-to-build-Windows-WinAPI-Dlls/PostBanner.jpg</featuredImage>
    </item>
  </channel>
</rss>