Enable TLS 1.2 or above on your ASP.NET Web App or WebAPI

The Transport Layer Security (TLS) 1.2 is a stadnard that provides security improvements over previous versions. More and more thrid-party APIs were configured to disable any requests from clients that were using TLS 1.0/1.1. So if your ASP.NET Web App or WebAPI Services Web Site will need to update to TLS 1.2 as well if your ASP.NET Web App or WebAPI Services Web Site has some calls to the third-party APIs, otherwise they will only return empty responses.

You could disable TLS 1.0/1.1 and only enable TLS 1.2 in your Web Server or in Azure, so that your hosting environments will no longer accept requests from earlier version of TLS.

But what happens on your application (ASP.NET Web App or WebAPI Services)? Depend on what version of .NET framework your project usrs will dicate the possible solutions available to you.

  1. If your project compiles against .NET Framework 4.7 or above, then you don’t have to do anything.
  2. If your project has been developed in a earlier version of .NET Framework, then you could either
    1. Recompile your project using .NET Framework 4.7 or above
    2. If recompiling is not an option, then you will have to update your .config file as below,
<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSystemDefaultTlsVersions=false"/>
  </runtime>
  <system.web>
    <compilation targetFramework="x.y.z" />
    <httpRuntime targetFramework="x.y.z" /> 
  </system.web>
</configuration>

It is preferred that x.y.z are the same. So if your application is 4.6.2, then replacing x.y.z into 4.6.2.

Microsoft also has post a useful document on describing the best pratices to TLS 1.2. It will be great if you could read them all and understand them in order to fully secure your application(ASP.NET Web App or WebAPI Services).
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls

 

Workaround on adding files or shortcuts to Quick Access in Windows 10

This afternoon, another MVP asked a question, how do we add a file or shortcut to Quick Access in Windows 10. He would like to do the same action as he could add a file or shortcut to Favorites in Windows 8 or before.

In Windows 10, “Favorites” is replaced by “Quick Access”. The “Quick Access” is letting you to browse into any folder in shortest route. If you want to add any folders to “Quick Access”, you could right click any folder and add it to “Quick Access” by selecting “Pin to Quick Access”.

After you pinned it to “Quick Access”, you could then remove it by right click and select “Unpin from Quick Access”.

But if you right click to any files or shortcuts, you will found out that there is no such option to add them into Quick Access. But if the files or shortcuts are often being executed, you could find it from the lower section of the Quick Access, “Recent Files”. But what about if they are not being executed often and you still want to add it to “Quick Access”? One of the work around way is, adding the Favorites to “Quick Access”. With this workaround, you could add any files or shortcuts to the Favorites and it will then appear to the Quick Access. On the other hand, it will be removed from “Quick Access” if you remove it from Favorites. The Favorites path in windows Explorer is “C:\Users\(username)\Links”.

Here is the regedit nodes that you have to add in order to enable “Favorites” add to “Quick Access”.


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HomeFolderDesktop\NameSpace\DelegateFolders\{d34a6ca6-62c2-4c34-8a7c-14709c1ad938}]
@=”Common Places FS Folder”


[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\HomeFolderDesktop\NameSpace\DelegateFolders\{d34a6ca6-62c2-4c34-8a7c-14709c1ad938}]
@=”Common Places FS Folder”

And here is the regedit nodes that you have to remove in order to disable “Favorites” add to “Quick Access”.

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HomeFolderDesktop\NameSpace\DelegateFolders\{d34a6ca6-62c2-4c34-8a7c-14709c1ad938}]


[-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\HomeFolderDesktop\NameSpace\DelegateFolders\{d34a6ca6-62c2-4c34-8a7c-14709c1ad938}]



Please note, You will need Administrator right to pass the UAC when you add/remove the regedit nodes.

 

MVC Performance in IIS – Part II

Last 2 weeks, I run MVC training kit to IIS 7.5 and was trying to figure out the baseline for the performance tuning for my project. I tested 3 Scenarios,

S1) Hosting MVC 1.0 Training Kit in Application under Default Website
S2) Hosting MVC 1.0 Training Kit in New Website with port 8081
S3) Hosting my company’s MVC Project in New Website with port 8082

And their result of max throughput on Default Page is around,

Result 1 Screen Shot
R1 Result Screen Shot

Result 2 Screen shot
R2 Result Screen Shot

R1) ~200/sec
R2) ~2980/sec
R3) ~410/sec

This time, I tested in more scenarios,

S4) Moving MVC 1.0 Training Kit to root of Default Website
S5) Hosting MVC 1.0 Training Kit in Application under New Website with port 8081
S6) Hosting my company’s MVC Project in Root of Default Website

And their result now are,

Result 4 Screen shot
R4 Result Screen Shot

Result 5 Screen Shot
R5 Result Screen Shot

Result 6 Screen shot
R6 Result Screen Shot

R4) ~225/sec
R5) ~2650/sec
R6) ~170/sec

OK, let me group the result in a table and so we could view all results more clear.

  In Root In Application
MVC 1.0 Kit in Default Website ~225/sec ~200/sec
MVC 1.0 Kit in New Website with port 8081 ~2980/sec ~2650/sec
Company MVC Project in Default Website n/a ~170/sec
Company MVC Project in New Website with port 8082 ~410/sec n/a

Now the results are showing that
1) The performance will be gained about 10% if you move the MVC project from Application under website into root of website.
2) The performance will be gained in a range from 240% – 1325%  if you move the MVC project from Default Webste to New Website.

MVC Performance in IIS – Part I

Recent, I am focusing on MVC/.NET/IIS performance because of my job duty. I have to try and running load test in order to get the number of max thoughput, so that I could figure out a baseline for the web projects in my working company. I then setup a computer to host IIS with MVC projects. Here is what I get,

Hardware:

Web Server
CPU: Core 2 Due E8400
Ram: 4Gb DDR2-800
OS: 64-bit Windows 2008 R2 Enterprise Edition
Data: SQL 2008 Express Edition (for training kit data) + XML files (for my project data)

Client Computer
CPU: Dual-Core E5300
Ram: 4Gb DDR2-800
OS: 32-bit Windows 2008 Enterprise Edition SP2

Test tool
Apache JMeter v2.3.4 with Java Runtime v6.0.200.2

Scenario One

  • Hosting MVC 1.0 Training Kit
  • Hosting as Application in Virtual Directory in Default Website
  • Separate Application Pool from default website
  • Testing with 100 threads, 500 threads, 1000 threads and 1500 threads
  • Max thoughput
    • Default Page: ~200/sec
    • About Page: ~190/sec
    • Customers Page: ~73/sec

Scenario Two

  • Hosting MVC 1.0 Training Kit
  • Hosting in New Website
  • Separate Application Pool
  • Max thoughput
    • Default Page: ~2980/sec
    • Customers Page: ~388/sec

Scenario Three

  • Hosting MVC 2.0 project in my working company
  • Hosting in New Website
  • Separate Application Pool
  • Max thoughput
    • Static data from class: ~410/sec
    • Opening XML data file: ~274/sec

Interesting, this is the first time I try to do some benchmark. And I found out the performance betweenVirtual Directory under Default Website and New Website is hugh. It is 15 times difference. I tried to look around and still cannot figure out the reason. I will come back  here later when I have some updates.

P.S., the above number of the max thoughput are just for reference. They might be up or down with difference hardware and applications installed. In my testing, Server CPU is running up to 100% already. So the bottleneck may be SQL service in same machine, network loading, Machine is not a “REAL” server hardware….etc.