Recent Comments



Rick Strahl
Friday

re: Programmatically Opening Windows Terminal in a Specific Folder

Looks like with the latest terminal updates we now get a good command line interface.

Open a folder:

wt.exe -d c:\temp

Open with a specific profile:

wt.exe -d c:\temp -p "cmd"

Colin Dekker
Friday

re: Programmatically Opening Windows Terminal in a Specific Folder

Edit Windows Terminal profile.json and add the following to the desired profile(s):

"startingDirectory": "."

Download the official .ico file from

https://raw.githubusercontent.com/microsoft/terminal/master/res/terminal.ico

Then, save the reg commands below to a .reg file, replacing [[USERNAME]] and save it. (The path to wt.exe is hardcoded but could easily be changed to an expandable string, too lazy myself πŸ˜› )

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal Here"
"Icon"="D:\\tools\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[[USERNAME]]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

Brad Patton
Thursday

re: Creating a generic Markdown Page Handler using ASP.NET Core Middleware

re: Creating a generic Markdown Page Handler using ASP.NET Core Middleware

@Rick. Thanks I was following the steps in the article and getting errors. I didn't see the information in the GitHub page until after I posted my comment. Really like the package and the ability to add Markdown quickly to a site. Thanks again.


Bill
Thursday

re: Creating Visual Studio Templates from your Web Projects

I know this is an old post, but I found it in 2020 trying to solve it. And it looks like you can actually do what you want.. just need one more step..

So modify the *.vstemplate file like you did to include the missing dll's...

  <Folder Name="bin" TargetFolderName="bin">
    <ProjectItem ReplaceParameters="false" TargetFileName="myMissingReference.dll">myMissingReference.dll</ProjectItem>
</Folder>

but in addition, also manually edit the template's *.csproj file. In there you will find several "Item Groups"... Either add a new one, or just add on your file(s) to an existing one that seems to be related like so...

<None Include="bin\myMissingReference.dll" />

Now, when you create a new Project based off your template.. you will get the bin folder with your missing dll's already there.


Alberto
Thursday

re: WPF Rendering DUCE.Channel Crashes due to Image Loading

Thanks you very much. I had the same problem and thanks to your post I saved a lot of time.


Rick Strahl
Wednesday

re: Creating a generic Markdown Page Handler using ASP.NET Core Middleware

@Brad - I've updated the post with code for both 3.x and 2.x setup instructions.


Rick Strahl
Wednesday

re: Creating a generic Markdown Page Handler using ASP.NET Core Middleware

@Brad - Hmmm... not sure why there should be any 'trial and error' when the documentation shows this syntax for 3.x applications here:

https://github.com/RickStrahl/Westwind.AspNetCore.Markdown#startup-configuration

The article pre-dates .NET 3.0, so somewhat expected that things change a little πŸ˜‰


Brad Patton
Wednesday

re: Creating a generic Markdown Page Handler using ASP.NET Core Middleware

Created a new ASP.NET Core 3.1 web application and tried to get this to work with endpoint routing. After some trial and error I was finally able to get it to process markdown files. The key line is to add endpoints.MapDefaultControllerRoute(); this will run the middleware controller on the static files. Otherwise the setup was similar to the setup listed in the article.

	public void ConfigureServices(IServiceCollection services) {
		services.AddMarkdown(config => {
			// Simplest: Use all default settings - usually all you need
			config.AddMarkdownProcessingFolder("/posts/", "~/Pages/Shared/__MarkdownPageTemplate.cshtml");
		});

		services.AddRazorPages();
	}

	public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
		...
		
		app.UseMarkdown();

		app.UseHttpsRedirection();
		app.UseStaticFiles();

		app.UseRouting();

		app.UseEndpoints(endpoints => {
			endpoints.MapRazorPages();
			endpoints.MapDefaultControllerRoute();
		});
	}

Joy Tan
February 11, 2020

re: Deleting Problem Folders and Files on Windows: Could not find this Item Error

Hi Rick,

I had this problem for the longest time ever!! You got this solved!! YAY!!!

Joy


Rick Strahl
February 10, 2020

re: ASP.NET Core In Process Hosting on IIS with ASP.NET Core

@Oisin - IIS has POST size limits. In theory they should hit regardless of whether you're running in proc or out of proc if you're running through IIS (unless you're running Kestrel directly).

Here are the settings that control the POST buffer size in an older blog post:

You can set the web.config settings in the config you push to your Azure site.


Oisin G.
February 10, 2020

re: ASP.NET Core In Process Hosting on IIS with ASP.NET Core

I hit something today where I found I was forced to switch to OutOfProcess hosting over InProcess (asp.net core 3.1) I have a REST API that needs to accept a very large POST of data (~32MB) and it fails in Azure and locally for InProcess with a 500 error that doesn't seem to get to my application at all (it's failing early) -- the POST succeeds with an out of process model. This is after having set the maxRequestSizeLimit to accommodate the data. I'm assuming it's some kind of hard limit / OOM for IIS Express, and some kind of worker process (w3wp) memory limit on Azure.


Tristano
February 09, 2020

re: Make your CHM Help Files show HTML5 and CSS3 content

Thanks Rick, an excellent article as always!

The solution of enabling IE9 emulation mode for the application to which the CHM file belongs is quite cool. The only downside is that if the end user opens the CHM Help file directly (instead of from the main app via H1) then it would launch in IE7 mode β€” which might end up looking quite ugly if the HTML contents and CSS were designed targetting IE9 mode.

Setting the registry to enable IE9 compatibility directly for HH.exe seems an interesting idea, but I too share Eric's concerns about this potentially breaking the intended styles of many CHM docs. You mentioned that this shouldn't be an issue since the HTML Help Viewer should safely fall-back to IE7 if the HTML contents don't target IE9 explicitly. Did you have a change to actually test tweaking the registry entry and see if and how it affected various CHM files?


Rick Strahl
February 08, 2020

re: Accessing Configuration in .NET Core Test Projects

@Franz - you should not use UserSecrets in production since it won't be available on a deployed machine most likely. UserSecrets is just available on the local dev machine and it works because it's only part of the IConfiguration chain of providers. IOW, in development the value is caught first from UserSecrets but in production, no user secrets so the configuration is actually pulled from the configuration file (or whatever other providers like Azure Key Vault) are set up.

You can roll your own configuration manager and store things in a JSON file, but the config system in .NET does all that for you. The downside is that if DI is not auto-provided you have to configure the configuration yourself as outlined in this post.


Franz
February 08, 2020

re: Accessing Configuration in .NET Core Test Projects

Hi,

I was wondering if what is explained in this article would be a solution for another kind of project than a Test.

I basically need to access User Secrets in a DAL project that is referenced into an Asp.Net Core project.

It's basically to provide my DAL with a connectionString and InvariantName. That seems "a lot of work" for two strings value..

What would you advise?

Thank you

ps : I am new to development


Rick Strahl
February 07, 2020

re: Enabling Internet Explorer Mode in Edge Chromium

@Alex - Yes I agree, although I doubt we'll actually get an OS owned update process because Edge will update independently of the OS it looks like. So I suspect that that the controls likely ship with specific versions of the Chromium runtimes that you bind to and it'll be up to the developer to keep that up to date. But who knows - Microsoft hasn't revealed much beyond the C++ examples a long while back.


Max
February 07, 2020

re: Live Reloading Server And Client Side ASP.NET Core Apps

Thanks Rick! Ctrl + F5 worked for me. I thought I was going crazy due to a CSS/HTML caching issue across all browsers while debugging a new ASP.NET Core 3.1 site. I attempted to override this behavior by using response cache attributes, added meta tags for cache control, and added response headers, all without any changes to the cache behavior. I even created an MVC site with .NET 4.7 to compare the caching, which was reflecting my changes correctly upon browser reload.


Alex Sarafian
February 07, 2020

re: Enabling Internet Explorer Mode in Edge Chromium

I agree on what you write about the embedded web browser control. It is from 2007 and although it works well as you say I wonder how secure it still is for authentication workflows.

On a previous project I had worked on we moved away from it by replacing it with a Firefox powered one called GeckoFX. Now we could run rich previews with modern JavaScript but we had other problems with it like integration,updates and x64bit support. The latter is solved but to my knowledge upgrading and integration is still problematic.

In my opinion the solution is to develop an API that is powered by the host OS which will own the upgrades and specifics of the engine similar to how secure web views work on mobile OSs


Rick Strahl
February 07, 2020

re: Live Reloading Server And Client Side ASP.NET Core Apps

@Jakob - those are two different things. You need the runtime compilation or else this tool won't actually work. You need to add and enable that. The compilation just handles making sure that the files are recompiled without reloading the entire server (which is very slow). The reload component will reload the active page.


Jakob StrΓΈm
February 06, 2020

re: Live Reloading Server And Client Side ASP.NET Core Apps

Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation does it do the same?, or are your solution more comprehensive? As far as i can read the RuntimeCompilation only handles cshtml/css files.


Dmitry
February 05, 2020

re: Passing multiple simple POST Values to ASP.NET Web API

It's been 8 years and a man from Hawaii saved [a week for] a man from Russia. I can't express how much grateful I am. Thank you.


Morten
February 04, 2020

re: Using the ng-BootStrap TypeAhead Control with Dynamic Data

Thank you for this blog. I was messing around a lot. I never had guessed the switchMap would be the solution. Fantastic..


Zak Willis
February 04, 2020

re: Serving ASP.NET Core Web Content from External Folders

Hi Rick, thanks for posting this. Sounds interesting and are looking for ways to have a kind of plugin related approach.


Daniel
February 03, 2020

re: Video Rendering Issues for WPF Windows

Adding the line of code you mentioned at the start of my application fixed the problem for me!

RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;

Thank you so much! This has been bothering me for a long time.


ALeX
February 01, 2020

re: Creating Single Instance WPF Applications that open multiple Files

Hello,

I jut wonder, does it also wroks with ClickOnce deployed applications ?

I need to do the same as you expose here, but the method you use here to get the arguments (Environment.GetCommandLineArgs()) does not tell me the filename I double clicked. It only returns the path to the exe.

How do you invoke the program ? Did you create a short cut to to the exe (where windows adds the argument on the command line) ?

Thank you for any hint here...


Dean
January 30, 2020

re: .NET Core 3.0 SDK Projects: Controlling Output Folders and Content

Thanks, Rick. I should have also said that I've enjoyed reading your blog for many years now, and this is the first time I've posted. The extra folders aren't a huge deal, but since it would be easy to clean-up with a post-build event, I'll do that.


Rick Strahl
January 29, 2020

re: .NET Core 3.0 SDK Projects: Controlling Output Folders and Content

@Dean - I don't think you can surpress those just like you can't surpress various libraries from creating resource folders if they have resources for different languages when an app is compiled.

You can clean that up post publishing/building though as part of your own publish to production process if it bothers you that much.


Dean
January 29, 2020

re: .NET Core 3.0 SDK Projects: Controlling Output Folders and Content

This page shows in a Google search when I try to find if it's possible to prevent the creation of the different country folders in the bin\NetCoreApp3.0 folder, so different question. Just now moving to core, and this bugs me. Also, the "Runtimes" folder with Unix subfolder, etc. Is it simple to prevent these? I'm currently working with ASP.Net Core app.


Blake
January 29, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

I ran into this issue a year ago when I had updated .NET Core NuGet packages but didn't have the updated SDK installed on my workstation.


Rick Strahl
January 23, 2020

re: Back to Basics: String Interpolation in C#

@Luiz - Might be different versions of the compiler and .NET Runtime. Core vs. Classic and different versions of C# compiler are likely to account for the differences.


Luiz
January 23, 2020

re: Back to Basics: String Interpolation in C#

Hi,

Great explanation. I tested the IL dumping using two different tools. LynqPad 5 as you mentioned and the result was exactly like yours. Also, I tested using ILDASM from Microsoft Visual Studio and the result is different.

O LynqPad 5 it says the interpolation is using String.Format, however on ILDASM it says interpolation uses String.Concat.

Questions: Do you know why LynqPad shows different results than ILDASM? Shouldn't we trust more on ILDASM since it is a Microsoft Visual Studio tool?


Rick Strahl
January 18, 2020

re: ASP.NET Core In Process Hosting on IIS with ASP.NET Core

@hess - Kestrel is the hosting interface that runs the ASP.NET Core application. It's the HTTP front end that provides the actual connections to the application. If you're running InProcess in IIS you can't have both Kestrel and IIS handling the connections. You can if you run OutOfProcess because OutOfProcess basically proxies to a separate Kestrel process (dotnet.exe).

Off the top of my head I don't know how IIS Express hosting works. I think the default hosting uses out of process hosting, but I think it probably depends on the project setting as well - I haven't checked recently.

In Visual Studio you can choose how you want to run your application in Debug mode: IIS Express, YourApp.exe (Kestrel standalone running dotnet.exe) or whatever else you set up and configure in launchsettings.json.


Hess
January 17, 2020

re: ASP.NET Core In Process Hosting on IIS with ASP.NET Core

You say "The In Process model does not use Kestrel".

Question: Is it still true when I explicitly ask for Kestrel in "Program.cs"?

"Host.CreateDefaultBuilder().ConfigureWebHostDefaults(webBuilder β‡’ webBuilder.UseKestrel())"

If yes, how does IIS Express which is spun up by Visual Studio in debug time can alter this and cancel Kestrel instantiating?


Rick Strahl
January 17, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

@Donnie - ASP.NET Core doesn't write the logs into wwwroot. It goes in the content root, which is the folder above it - wwwroot is a sibling folder to that. IOW, you can't access the logs via HTTP requests, so I don't think there's anything wrong with how that works.


Rick Strahl
January 16, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

@zjaadc - yup. Probably added recently when this was discovered.

But honestly even if I read this chances are I wouldn't have fixed it buried in all of this. In my case I didn't even realize I had the back reference in place it was likely imported inadvertently by a stray reference in the code from beta times.


zjaadc
January 16, 2020

Anders
January 15, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

Great post, we're in Germany and I'm sure it will help us as we're going to be deploying our app in about 5 months. However, I took a look at the thread on twitter and you omitted something in your post. You said,

@JustinKotalik on the ASP.NET team spotted my Github Issue and pin-pointed the solution only a little while after posting on Github:

That isn't what I saw. There was a non-microsoft guy that nailed it first before any of them and wasn't even mentioned in this post, just thought I would point that out because you're crediting the guys that created the problem in the first place πŸ˜ƒ

Anyway, thanks for the post and for posting the twitter links so we could follow the progression. People like you don't get enough thanks for the valuable service you perform by running up against issues and then making sure guys like us don't have to spend the hours of anguish trying to figure out what the heck went wrong.


Donnie Hale
January 15, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

Rick,

Thanks for the post. One comment. As far as I know, the web.config that results from a "dotnet publish" still includes the stdout log file location of ".\logs\stdout". That's wrong and should be corrected by MS. I spent a couple of days on the phone w/ MS Azure support dealing with an ANCM issue. One recommendation coming out of that was that an application should never write to the "wwwroot" folder in an Azure app service.

For something running locally, it may not be a problem. But as is documented in other places, the better value for the stdout log file location is "\?%home%\LogFiles\stdout". Once I made that change in the app service's web.config, tracking down the real source of the error was quick.

-Donnie


Rick Strahl
January 15, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

Thanks @tune - fixed.

@rich - I don't know if I agree. web.config has never been a big issue for me. Maybe in the early .NET 2.0/3.x days, but in recent years there was very little that needs to be configured as the defaults were good. And those are the same defaults you use with .NET Core now.

And remember - Kestrel is just an application web server, it's not a full Web Server that provides the hosting and Web support infrastructure. If you're just talking about Kestrel you still need IIS or something else to provide security, SSL, Caching etc. and THAT'S really what's causing the extra configuration nightmares in IIS for the most part. You will still have those with .NET Core unless you use some other host.


rich
January 15, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

I've seen that error but in my case it was when I'd updated an app to 3.1 and not installed 3.1 on the server.

I find .NET Core 3.1 the most insane aid to productivity since I started developing in 1985.

Did you ever think we would have XCOPY deployment of websites on Windows? No more bizarre error messages! No more spelunking through gargantuan web.config files trying to find the cause! No more deployment wizard!

Instead a vestigial web.config file to keep IIS happy, copy all the code into a folder, and move on with your day !


Tune
January 15, 2020

re: ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

Thank you Rick,

For your comprehensive post! I stumbled upon a few minor typos:

  • Damien Edwards β†’ Damian Edwards (twice)
  • packages/assmeblies β†’ packages/assemblies
  • Apparently when there one β†’ Apparently when one
  • buyt β†’ but

Thanks for your sharing your experience(s)! Tune


Sanjay Gupta
January 15, 2020

re: FontAwesome Fonts and Mime Types in IIS and other Web Servers

In case it is still giving HTTP-404 error for .woff and .woff2 file types, add them in request filtering and it will work.


Rick Strahl
January 12, 2020

re: Using the ng-BootStrap TypeAhead Control with Dynamic Data

@Richard - this control is very funky in its behavior in other ways too, and to me at least damn unintuitive. I had no luck getting the converters to do the right thing, turning the result value from an object into a single string value for example. It worked for display, but the final value binding - not so much. I ended up having to change my service data returned to make this work 😏


HDN
January 12, 2020

re: Back to Basics: String Interpolation in C#

Great article. Thanks for clearly pointing out that this feature cannot be used as a template system.


Peter Drinnan
January 12, 2020

re: Using the ng-BootStrap TypeAhead Control with Dynamic Data

I agree with Asad. Would never have figured this out using the offical docs. This is the best example I have seen so far. Been on a dozen sites looking for something like this. Thanks so much.


Richard Bond
January 11, 2020

re: Using the ng-BootStrap TypeAhead Control with Dynamic Data

Thanks for this!

I struggled with this on my own site for a week before settling on a hacky work-around. With this new information, I'm excited to go back and do it "right".


Coy Meeks
January 07, 2020

re: Accessing Configuration in .NET Core Test Projects

Good stuff, Rick! To heck with mocking IConfig when you can just use the real thing! πŸ˜ƒ

I wanted to check with you to see if you've ported this to work with Xunit. On my end, it doesn't appear that you need to specify the outputPath of the config and I wanted to confirm there would be no issues. Thanks again!


Rick Strahl
January 07, 2020

re: A few notes on creating Class Libraries for ASP.NET Core

@Evgeny - it depends on who your target is. If you're building internal infrastructure and you control what's being used then using full framework references is the way to go to keep maintenance minimal.

But if you're a library creator for a lib that's used by a general audience, you want to be careful to minimize dependencies to just what you need rather than forcing a full framework (and potentially a specific version thereof) on all your dependent users.


Evgeny Gorbovoy
January 07, 2020

re: A few notes on creating Class Libraries for ASP.NET Core

I'm going to reference exactly big meta package, because I'm moving almost everything from executable to satellite assembly and I can't spend time on finding appropriate package for everything. And as for me, netcore team should not expect that developers will do it. I'll also try to change SDK of assebly from Microsoft.NET.Sdk to Microsoft.NET.Sdk.Web, but that requires the creation of entry point.. All this things throw me off, honestly.