Tuesday, April 29, 2025

WSDL Https service meta data error

 Change IIS to: SLL Settings uncheck Require SSL and Client Certs : ignore.

Friday, February 21, 2025

Dev Blog: Exporting a Database with SqlPackage.exe and Creating Users in SSMS

A streamlined process to export a SQL database using SqlPackage.exe and tackle common issues such as orphaned users and certificate errors. I’ll also include a brief guide on how to create a user via SQL Server Management Studio (SSMS).

Exporting the Database with SqlPackage.exe

  1. Prepare the Database:
    Ensure that your database has all necessary data and that any users are correctly linked to their corresponding logins. If you have orphaned users (users without matching server logins), either remove them or create the corresponding logins.

  2. Use SqlPackage.exe: (Can be downloaded from microsoft or installed with dotnet.exe
    Use the following command from a Command Prompt or PowerShell session to export your database to a BACPAC file. 

    batch
    SqlPackage.exe /Action:Export /SourceConnectionString:"Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=True;Encrypt=True;TrustServerCertificate=True;" /TargetFile:"E:\BackupSites\YOUR_DATABASE\YOUR_DATABASE.bacpac"

    Replace YOUR_SERVER, YOUR_DATABASE, and the target path with your actual server name, database name, and desired file location.This example assumes Windows Authentication and includes parameters to trust the server certificat

Troubleshooting Common Issues

  • Orphaned Users:
    If you encounter errors about orphaned users during export, verify that each user in the database is associated with a corresponding login.

    • Solution: Either remove the orphaned users or create matching logins and link them using:

      sql
      -- Create login if not exists IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = 'UserName') BEGIN CREATE LOGIN [UserName] WITH PASSWORD = 'YourStrongPassword!' END USE YourDatabase; ALTER USER [UserName] WITH LOGIN = [UserName];
  • Certificate Issues:
    If you see errors like "The certificate chain was issued by an authority that is not trusted," add TrustServerCertificate=True (or set Encrypt=False if encryption is not needed) in your connection string.

Creating a User via SQL Server Management Studio

  1. Create a Login:

    • Open SSMS and connect to your server.
    • In Object Explorer, expand the Security folder.
    • Right-click on Logins and select New Login...
    • Enter a login name and select the appropriate authentication method (e.g., Windows Authentication or SQL Server Authentication).
    • Click OK to create the login.
  2. Map the Login to a Database User:

    • Expand the newly created login under the Logins folder.
    • Right-click on the login and choose Properties.
    • In the User Mapping page, select the database you want the user to access.
    • Check the Map checkbox and assign the necessary database role memberships.
    • Click OK to complete the process.

Using these steps, you can ensure a smooth export process with SqlPackage.exe and properly manage user logins and mappings within SSMS.

Finally, to import the BACPAC file into Azure using SSMS, connect to your Azure SQL Database. In Object Explorer, right-click the Databases folder and choose Import Data-tier Application. The Import wizard will prompt you to select a local BACPAC file; browse to the file you created earlier. Specify a target database name and configure any additional settings such as service tier and performance level. Follow through the remaining steps of the wizard to complete the import process. Once finished, your Azure SQL Database will contain the imported schema and data from your original database.

This approach helps you manage potential issues during export—such as orphaned users and certificate errors—and provides a clear workflow for both exporting with SqlPackage.exe and importing into Azure via SSMS. Happy coding and troubleshooting!

Monday, April 15, 2024

Update swagger

 Right click projekt then ADD then REST API Client (Create new) or Connected Services (Manage existing)

Monday, January 15, 2024

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

Friday, March 4, 2022

Windows 10 - Kill process on specific port



This will show you the process id. Now we can kill it with this:

taskkill /PID 19592 /F 


Monday, February 28, 2022

EPiServer - Scheduled Job not running on schedule reminders

  • Check if jobs have hanged in "running state in db". See other blog article.
  • Check if server time is actually what Episerver is using.
  • Check that the scheduled user is using a account that has rights. (job runs as other user than manual).
  • See if other jobs are running an blocking.
  • Set: <episerver><applicationSettings enableScheduler="true"

Wednesday, January 26, 2022

NPM - Node - Troubleshooting


 


Got an ugly error that didn't give me much info at all.

Cannot convert undefined or null to object.

After alot of head ache i started checking each npm package one by one with the tool

npm-check. So useful. In the interactive mode i could just install each missing package since i had tried removing npm-modules folder.

somehow the package install of gulp-modulizr was not getting a package back it seems it should be spelled modulizr-gulp. i tried removing it and now it works.


normal install of win node doesn't seem to work ok with nvm either so...

Tuesday, November 23, 2021

Visual Studio - Remove Unused Configuration Profiles

Get-Project -All | Foreach { $_.ConfigurationManager.DeleteConfigurationRow("Release") }

Sunday, November 21, 2021

Powershell - Add Permanent Environment variable

These are the two PowerShell commands you need to permanently update the Path environment variable Start as ADMIN.

PS C:\Users\donald> Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value ($Old_Path += ';z:\Dropbox\prio\')

PS C:\Users\donald> Get-Item Env:Path|fl