Monday, November 28, 2022

Escape Json in Html Razor

  data-campaign-category="@Html.Raw(HttpUtility.JavaScriptStringEncode(Model.SetCampaignData()))">


  string json = JsonConvert.SerializeObject(blackFridayCampaign, Formatting.None, new JsonSerializerSettings(){ StringEscapeHandling = StringEscapeHandling.EscapeHtml});

Tuesday, May 24, 2022

Window devenv path

 




How to clear visual studio cache

Many times, during development you would face situations where project references are not loaded properly or you get missing/error DLL's. This is because the Component cache gets corrupted randomly and without any warnings. The first option that needs to be done is to clear component cache and restart Visual Studio since the Cache might be holding onto previous DLL versions. Here are the steps on how to clear Visual Studio Cache,

Clearing Component Cache:

  1. Close all Visual Studio Instances running in your machine. Also, make sure devenv.exe is not running in the Task Manager
  2. Delete the Component cache directory -%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\1x.0\ComponentModelCache
  3. Restart Visual Studio
The above steps should fix the cache issue most of the times, but some times that is not enough and you need to perform the below steps as well.
Clearing User's Temp Folder:
  1. Open the temp folder in this location - %USERPROFILE%\AppData\Local\Temp
  2. Delete all the files in the temp folder
If both of the above-listed steps don't work there is a final option(hard-route option) that you could try to clear cache in Visual Studio.
Delete the files from these locations
  1. %USERPROFILE%\AppData\Local\Microsoft\Team Foundation
  2. %USERPROFILE%\AppData\Local\Microsoft\VisualStudio
  3. %USERPROFILE%\AppData\Local\Microsoft\VSCommon
Run the below command after deleting the files from the above folders,
C:\Program Files (x86)\Microsoft Visual Studio 1x.0>devenv /resetuserdata
This command will reset the user information in VS. Please make sure you export your settings under Tools -> Options before running this command

Tuesday, April 12, 2022

Create https cert locally for IIS and others.

1. Use Choco install to install mkcert.

2. Add mkcert to your local root CAs.

3. In terminal run mkcert -install

This will generate a local certificate authority (CA). Your mkcert-generated local CA is only trusted locally, on your device.

Now we need to generate a certificate for your site, signed by mkcert.In your terminal, navigate to your site's root directory or whichever directory you'd like the certificates to be located at.

mkcert localhost

OR

mkcert mysite.example

For use on IIS use the format pkcs12.

mkcert -pkcs12 somedomain.net

NOTE: replace somedomain.net with the domain you will be using locally. You can specify multiple domains (space-delimited) and even wildcard subdomains via *.somedomain.net

The command above will create a somedomain.net.p12 file in the folder where you invoked the mkcert command. This file is a PKCS#12 certificate, which is what IIS requires.

Rename the .p12 file to .pfx

IIS expects imported PKCS#12 certificates to have a .pfx extension. Be sure to rename the generated .p12 certificate to .pfx


Now the cert needs to be imported in the MMC certificates store or whatever.

To be able to then be append the https cert binding in IIS.


Right click on the window and file to import.

select your cert.

It will require a password that is specified in the response from mkcert when creating it.

Fore info

https://web.dev/how-to-use-local-https/


OBS: Note when you add this cert to IIS use the "Rquire Server name Indication"

Web.Config - Make it more readable with outlinining

 Turn on outlining on - EDIT - Outlining (CTRL-M + CTRL-L)

Then to unfold every section select everything and press:

CTRL+M+ CTRL + M