Recent Comments



Shail
Wednesday

re: Flexing your HTML Layout Muscles with Flexbox

Awesome article, Rick! Very lucid! Cleared most of my doubts about Flex, and the examples went a long way in my understanding too.

I think you just might want to take a look at the sentence below and rectify it:

If the value is non-zero and the element can grow or shrink and the value is used as a ration in relation to the other other elements in the container.

It appears in the second para just after Figure 1 that talks about individual Flex item attributes.

Shail


Chris
Wednesday

re: A Visual Studio to Visual Studio Code Snippet Converter

I'm in love with snippets. Thank you for this!


Rick Strahl
Tuesday

re: Using Let's Encrypt with IIS on Windows

@Niko - LetsEncrypt won't renew domains that you haven't set up with LetsEncrypt in the first place. So if LetsEncrypt is trying to update that domain you must have set up a certificate at some point.

Using Win Acme (formerly Lets Encrypt Win Simple) there's an option to show all managed certificates and to remove specific domains from the renewal cycle.


Niko
Tuesday

re: Using Let's Encrypt with IIS on Windows

Hello, I'm working with your script for over one year. It is working well! There is one thing I would like to know: I have some sites which are secured with comodo certificates. Today a customer called me that the SSL binding was down. The script had renewed a LetsEncrypt certificate instead of the customers comodo cert but did not bind it to the domain on port 443. So what I would like to know: How can I exept a domain from renewing the certificates with LetsEncrypt certificates? I already tried to delete it in the certificate console and all files with domain*.* below C:\Users\Administrator\AppData\Roaming\letsencrypt-win-simple\httpsacme-v01.api.letsencrypt.org But after 3 months all is back again an my customers cert is unbind. I don't know if it matters to delete and recreate the site in IIS - I did not already tried. Would be great to get a workaround from you! Best regards

Niko


Marcelo
Monday

re: Getting JavaScript Properties for Object Maps by Index or Name

Awesome! Saved me a bunch of 'research hours' by trial and error! Thank you!


Rick Strahl
December 31, 2018

re: Publishing and Running ASP.NET Core Applications with IIS

@Alex - to confuse things a little more, ASP.NET Core 2.2 by default now uses InProcess hosting in IIS with its own .NET Core Module that loads the runtime without the external dotnet.exe. This is closer to the old .NET runtime hosting in IIS and should improve throughput significantly - the old proxy way also still works so it'll be easy to compare performance.


Rick Strahl
December 31, 2018

re: Don't let ASP.NET Core Console Logging Slow your App down

@Mani - yeah I use Serilog in most production apps as well but for test and play projects the internal logging is 'just there' and it works well.

Still not clear why the Console logger is so slow. The default implementation in 2.x and later uses a queue to buffer the messages and I can see the intermediate queue handling in the code firing and not directly writing, but it's still deadly slow. I wonder if the queue synchronization itself is so slow as the request count gets big that it's actually not much faster than the Console.Write() calls. Seems odd.


Mani Gandham
December 31, 2018

re: Don't let ASP.NET Core Console Logging Slow your App down

We ran into this too with console logging.

System.Console.Out is a TextWriter for stdout and that already supports WriteAsync and WriteLineAsync so replacing the default Console logger with a custom one with a in-memory buffer and async methods removed all the blocking and latency overhead.

This is also much easier to do with Serilog or other logging frameworks that have more fine-grained configs around logging outputs.


Luke
December 30, 2018

re: Opening a Web Browser with an HTTP Url from Visual Studio Code

Hey, Rick thanks for the info you provided in your post. I didn't know that you could do that with a built-in function, like the Task is. Anyway, I've been using this extension for a year now and it's great. Technically it does the same thing, just without the hassle of the developer to have to create this kind of tasks. 😃

https://marketplace.visualstudio.com/items?itemName=igordvlpr.open-in-browser


Alex
December 29, 2018

re: Publishing and Running ASP.NET Core Applications with IIS

Thanks for a plain english explanation, really. "IIS acts as a reverse proxy" - why has no one said it before?

PS. Even though we're still trying to figure out the big question - should one move to ASP.NET Core at all if he runs on Windows/IIS?


Ryan
December 27, 2018

re: Which .NET Core Runtime Download do you need?

Thanks for the excellent breakdown. This is something I have to be mindful of constantly. Our organization leverages several cloud platforms and even has an internal Cloud Foundry implementation. With Cloud Foundry, I find myself constantly having to be mindful of SDKs and runtimes and have to use the global.json to ensure that what I'm building locally can actually be pushed into a Cloud Foundry container based on what dotnet core buildpack has been applied on the servers and what versions of the SDKs it supports.

I know that using the global.json may not be a common use case but it's sure convenient when you need it!


Adam Cook
December 21, 2018

re: Which .NET Core Runtime Download do you need?

Hi Rick,

Thank you for your information. Honestly, I'm quite confused which version need to be installed. I test .net Core 2 on my localhost and it works. But, when I deployed to my hosting (Asphostportal), it is not stable. Sometimes it will work fine, but sometimes it will throw an error. Is there a bug on .net core? Just curious.


Rick Strahl
December 20, 2018

re: Using FontAwesome Fonts for HTML Radio Buttons and Checkboxes

@Isabel - I wonder why this is a problem because the underlying checkbox is still used - it's just not visible. A speech tool should be able to pick this up.


ISAbel Holdsworth
December 20, 2018

re: Using FontAwesome Fonts for HTML Radio Buttons and Checkboxes

This is a great technique, but unfortunately it doesn't work with speech recognition software such as Dragon Naturally Speaking. We've been trying to resolve this for months and nothing works except for exposing the native checkbox.


Sébastien
December 12, 2018

re: Hosting SignalR under SSL/https

For those with the same issue as Olivier Clare and Markus Wagner, it's probably because of TLS version not enabled for the version of net framework you use. I had the same issue and also took me a while to find the root cause. Following this StackOverflow link for details: https://stackoverflow.com/a/46223433


Rick Strahl
December 09, 2018

re: Publishing and Running ASP.NET Core Applications with IIS

@Eduard - correct. Kestrel requires exclusive access to a port in order to work. If the port is already in use Kestrel will fail to launch, and http.sys won't be able to reserve a port if kestrel is already using a port.


Rick Strahl
December 09, 2018

re: GZip/Deflate Compression in ASP.NET MVC

@ahmed - this is for programmatic compression.

Static and Dynamic compression are configured in IIS. If you're using dynamic compression in IIS then you probably don't want to use programmatic compression as well - one or the other.

Here's another blog post that talks about those options: https://weblog.west-wind.com/posts/2011/May/05/Builtin-GZipDeflate-Compression-on-IIS-7x


Eduard Riera
December 08, 2018

re: Publishing and Running ASP.NET Core Applications with IIS

Kestrel doesn't use http.sys kernel driver. Is there a concept of port reservation in Kestrel? What happens if http.sys and kestrel tries to use the same port? If http.sys already have the reservation (even if nothing is currently listening) kestrel cannot use the port?


Bishal Adhikary
December 06, 2018

re: Strongly Typed Configuration Settings in ASP.NET Core

Awesome post! I am working on my ASP.NET core based project and have been feeling a little uncomfortable using appsettings.json. I am still not sure if appsettings.json gets parsed at runtime or compile time which is why I have been hardcoding some of the more frequently used settings directly in the methods(I definitely would not prefer it parsing the JSON at runtime). Will give your appraoch a try.


Ahmed
December 06, 2018

re: GZip/Deflate Compression in ASP.NET MVC

Dear Rick, Thanks a lot for your post really it is too useful for me. i just have a question , if this approach will fit to dynamic and static compression or for dynamic only? What should i do to handle static compression ? do i have to handle it through IIS ?


Chris
December 04, 2018

re: Using Let's Encrypt with IIS on Windows

Really useful - thanks so much for this post. IIS certificate installation completely painless. Your blog now bookmarked!


Marcel
November 17, 2018

re: ASP.NET Core and CORS Gotchas

Dear Rick, Thank you for your enlightening post. I am struggling with the ‘withOrigins’ functionality of the builder. I managed to add multiple domains hard coded by separating them (see code below), but I would like to set those domains dynamically (from a json-file or from a database). Is that possible?

options.AddPolicy("CorsPolicy",
    builder => builder.WithOrigins("http://www.domain1.com","http://www.domain2.com")
    .AllowAnyMethod()
    .AllowAnyHeader()
    .AllowCredentials());

Rick Strahl
November 16, 2018

re: Creating a .NET Global Tool from an existing Console Application

@Jon - sure you can do that, but you're still dependent on the .NET Core SDK and Runtime to run this. Global tool solves this problem. Having a .bat/ps1 file to do this for you is a bit hokey at least for a non-internal tool. Note that you can do a local install via dotnet tool install with a --add-source= pointing at a local folder which gives you a global tool without having to install from a public package manager.


granadaCoder
November 16, 2018

re: Strongly Typed Configuration Settings in ASP.NET Core

Thanks @Sean Fackrell. That is the "collection" example and magic syntax sugar (the "List" comment) that I needed. Thanks Ricks for the post.


Allen Salinas
November 16, 2018

re: Custom Message Formatting in WCF to add all Namespaces to the SOAP Envelope

Thank's a lot for this information. After many days trying to figure it out, this post helped me to do it. Again, thanks from Colombia.


Jon Seeley
November 15, 2018

re: Creating a .NET Global Tool from an existing Console Application

Rick your post for this was quite timely as I had just barely decided to convert an old full framework console application over to .NET Core last week. I hadn't even got far enough to try to run it outside the debugger when I happened to pull up your blog and lo!, you're telling me that it won't compile as an exe.

For what it's worth, I figured you can also just create a simple batch file to put alongside your application and have dotnet MyConsoleApplication.dll -c Release %* (or %1, %2, etc for passed in arguments)?


Dan
November 13, 2018

re: More on ASP.NET Core Running under IIS

I just wanted to thank you for this, it just saved me major headaches. We were doing performance testing on our new .net core app and we were getting horrible results compared to our previous version (non-core). This was the only article I could find that hinted at static files being the issue and so I switched it to use IIS to serve the static files and we instantly saw a 400% increase in performance. Thanks!


Reginaldo Villela
November 13, 2018

re: Multi-Targeting and Porting a .NET Library to .NET Core 2.0

Hey Rick!

thanks for answering me.

I did the following to solve my problem.

For each framework version, I changed the AssemblyName of each output. So I can get a file with a different name for each version of the framework. See below how it was:

<PropertyGroup Condition="'$ (TargetFramework)' == 'net471'">
  <AssemblyName>DbConnector.Net471</AssemblyName>
  <DefineConstants>NET471;NETFULL</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$ (TargetFramework)' == 'net472'">
  <AssemblyName>DbConnector.Net472</AssemblyName>
  <DefineConstants>NET472;NETFULL</DefineConstants>
</PropertyGroup>

Rick Strahl
November 10, 2018

re: Multi-Targeting and Porting a .NET Library to .NET Core 2.0

You know I'm not sure if you can change the name of the assembly in an SDK project. I think the project is what determines the output of the package. You could however rename the file after build and that should work - there's nothing magical about the file name as it's just a container for the binary module.


Rick Strahl
November 10, 2018

re: Slow Connections with Sql Server

I've never seen problems with . for local servers either with SQL (which definitely works) or with server designations from a command prompt or powershell.


JustMe
November 10, 2018

re: Slow Connections with Sql Server

In the connection string, do not use the . [dot] or local for 'server'. Use localhost or an FQDN instead. While the . [dot] or local are valid (and still documented), they no longer work well with newer Windows/SQL/Powershell versions. Not sure if this fixes slow connections, but it resolves quite a few other issues including failed connections. Unfortunately, Microsoft is unwilling to document this new behavior.


Reginaldo Villela
November 09, 2018

re: Multi-Targeting and Porting a .NET Library to .NET Core 2.0

Hey Rick, how's going?

Congrats for article... awesome!

Is it possible to change the name of the DLLs by putting the framework version at the end (Ex: myconectionNet471.dll) and generating all in the same directory?

Thanks! Reginaldo VIllela


Steve
November 09, 2018

re: Dealing with Anti-Virus False Positives

Hi Rick

Thanks for this article. Just ran into a similar issue after upgrading InstallShield to 2018 R2. Swapped to Inno Setup and the Anti-virus false-positives disappeared.

Maybe something to do with not recognising the latest InstallShield version?

Thanks once again.

Steve


Mizumaky
November 07, 2018

re: Windows 10 Bash Shell Network Connectivity not working?

Tried many methods which didnt work when finally TURNING OFF my Kaspersky Free ANTIVIRUS helped me with the network problems. (by turning off i dont mean just pausing protection)


James MacIvor
November 05, 2018

re: ASP.NET Core and CORS Gotchas

Just a note for anyone who's having a rough time on an Azure deployment and somehow reads down this far. If you configure CORS in Azure via the portal then it will override your code CORS policies. This means that if you are using .WithCredentials and .AllowAnyHeader and etc then all of that will inexplicably stop working. Once you remove the Azure configuration then it will work normally.

You should add your any string values (like origin) as an AppSetting, but let ASP .NET Core (and not Azure) handle the CORS implementation.


Rick Strahl
November 04, 2018

re: Web Assembly and Blazor: Re-assembling the Web

When it comes to browser client side stuff, Microsoft has just never gotten it right. Never. Ever. So all the trepidation I hear from you in the comments - I agree and I said so in the post. I do like the way Blazor works, but after talking with a number of people outside of the Microsoft space in the last few weeks I'm almost certain that Blazor will be complete failure because nobody outside of the Microsoft already using Razor and server side ASP.NET space will get it. That's too small of a market to make a difference and for something like this to survive I think. The eco-system will just be too small to be functional and to be carried forward. Even it if becomes moderately popular in the MS space, Microsoft is likely to lose interest and ditch it just like all other client side technology.

I'd change my mind if MS would step up and push this in a bigger more public way, but that's clearly not happening at this point. If that doesn't change, Blazor is destined to be a niche tool...


Felice Ferri
November 04, 2018

re: LINQ to SQL and attaching Entities

Had exactly the same problem.

In my case, the problem was because I was using the same Context to perform a Query.

I mean, I looked for the Record if it didn't exists I did an InsertOnSubmit, if it did exists I did an Attach and there is where it failed (Did everything, rowversion column, tagged as timestamp in the .dbml etc)

When I decided to create to different instances of the Context, one for the search of the existence of the record, dispose that and then instantiate a new one for the Attach/Insert is just worked.


Adam
November 03, 2018

re: Web Assembly and Blazor: Re-assembling the Web

Adding to the comment above... It is sad the way Microsoft has been going about this. I'm sure all of us remember the massive hype around the release of Angular by Google, which in early versions was less functional than Blazor at this point, but still got an official release! It feels like Microsoft 'fell' into Blazor by accident, only to reveal that it does NOT match it's corporate bottom line - the increase of revenue of Server-side platforms/Services/resources - also known as Azure. So, in order to enjoy the benefit of all the interest in Blazor they will release some server side functionality... instead of that it is supposed to be - client side code running by the Browser. Sorry to be the one to rain on this parade, I would be happy to be proven wrong, Adam 😦


Chris Bailiss
October 30, 2018

re: Capturing Performance Counter Data for a Process by Process Id

Useful code Rick, thanks.

Re: the problem described above of counters shuffling, e.g. when one instance of chrome closes. I took the following approach:

  • Use the .NET Process class to track all running instances of the EXE I am interested in monitoring.
  • When any of these instances exits, I get all of the perf counters again using GetPerfCounterForProcessId().

This approach works because the .NET Process class is quite lightweight and it means I don't need to continuously call the heavy (but useful) GetPerfCounterForProcessId() to validate that none of the instances have shuffled around. It is still a faff though. It's fairly unbelievable Windows has been around for so long and there is still no way to directly lookup a Performance Counter using a Process ID...


Adrian
October 30, 2018

re: External Network Access to Kestrel and IIS Express in ASP.NET Core

As for binding to non-localhost URL in Kestrel, why not just modify the applicationUrl in launchSettings.json?


Rick Strahl
October 29, 2018

re: Slow Connections with Sql Server

@Scott - Yeah that's what I thought - but I tried on a few different machines including a VM that's not part of any Windows network. Each one of them is slow. And you would think named pipes would first look for local connections before jumping to another machine given that it's an explicit server specification. I use named pipes via code in some local applications on my dev machines for inter-process communication and that's not slow - connections/responses with that are instant.


pixelda
October 29, 2018

re: Easy Configuration Binding in ASP.NET Core - revisited

I'm using MVC 2.1 and it is likely that services.AddConfiguration() is now part of the internal start up. As always Rick, an informative and useful article


Scott Ferguson
October 28, 2018

re: Slow Connections with Sql Server

From my understanding, if anything, Named Pipes should be quicker than TCP/IP. I wonder if the fact that you're not seeing that is more of a reflection of your network?

Anyway, according to the MS docs: "Generally, TCP/IP is preferred in a slow LAN, WAN, or dial-up network, whereas named pipes can be a better choice when network speed is not the issue, as it offers more functionality, ease of use, and configuration options."

Check it out for yourself here: https://docs.microsoft.com/en-us/sql/tools/configuration-manager/choosing-a-network-protocol?view=sql-server-2014


Paul
October 28, 2018

re: Fixing Visual Studio Intellisense Errors

One thing to add to this, particularly in older versions of VS, is that hibernating or sleeping your laptop, after a long day's night, can also play hokey with the old IntelliSense.


Ayush Choudhary
October 27, 2018

re: Entity Framework and slow bulk INSERTs

Hi Rick,

Can you explain how batching will work here. I am reading the IIS Logs and creating JSON line by line and pushing to API.

Here is my API:

public async Task Post(IISLog iislog) { if (!ModelState.IsValid) { return BadRequest(ModelState); }

        db.IISLogs.Add(iislog);
        await db.SaveChangesAsync();

        return CreatedAtRoute("DefaultApi", new { id = iislog.Id }, iislog);
    }

Gilson
October 26, 2018

re: WCF WS-Security and WSE Nonce Authentication

Hi Rick, good afternoon.

Thanks for this article.

I'm following it, but I'm getting the error: System.ServiceModel.FaultException: 'The message has expired'

Already tried add:

binding.OpenTimeout = new TimeSpan (0, 10, 0);

binding.CloseTimeout = new TimeSpan (0, 10, 0);

binding.SendTimeout = new TimeSpan (0, 10, 0);

binding.ReceiveTimeout = new TimeSpan (0, 10, 0);

But I still get that error.


Steve Harrison
October 24, 2018

re: Excluding the node_modules Folder in Visual Studio WebSite Projects

Although the trick of hiding the folder didn't work for me in VS 2017, you explained the nature of the problem perfectly, and that's half the battle. Thanks!


Eric Newton
October 24, 2018

re: Which .NET Core Runtime Download do you need?

Wow, this is a great breakdown summary and big picture info for NetCore

Thanks for this, Rick!