16 Kasım 2020 Pazartesi
Angular için vs code eklentileri
Angular Language Service
npm Intellisense
ngrx for Angular 2 Snippets
TypeScript Toolbox
npm
TsTools
Angular Snippets (Version 9)
Types auto installer
Debugger for Chrome
TypeScript Importer
TypeScript Hero
vscode-icons
Add Angular Files
8 Kasım 2020 Pazar
QueryParamsModel
7 Ekim 2020 Çarşamba
KONUMA GÖRE MESAFE HESAPLAMA
2 Ekim 2020 Cuma
IIS Site Yedek Alma - Siteyi Güncelleme PowerShell Script
Yedek alıyor, uygulamayı durduruyor, dosyaları güncelliyor, uygulamayı açıyor.
WebApi
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
Write-Host "Yedekleniyor...";
$from = "C:\WebSites\akifsite.com\_Current\*"
$to = "C:\WebSites\akifsite.com\_Old\"+(get-date).ToString('yyyy_MM_dd-hh_mm_ss')+"\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host $to " klasorune yedeklendi";
$FileName = "C:\WebSites\akifsite.com\_New\Api\web.config"
if (Test-Path $FileName) {
Remove-Item $FileName
}
$FileName = "C:\WebSites\akifsite.com\_New\Api\appsettings.json"
if (Test-Path $FileName) {
Remove-Item $FileName
}
$siteName = "akifsite.com"; #poolState name aynı diye bunu kullanıyorum, farklı olsa poolName eklemek lazım - akif 30.09.2020
$poolState="";
$siteState ="";
$currentRetry = 0;
Write-Host $siteName " durduruluyor...";
do{
$siteState = (Get-WebsiteState $siteName).Value;
$poolState = (Get-WebAppPoolState $siteName).Value
if($siteState -eq "Started"){
STOP-Website $siteName;
}
if($poolState -eq "Started"){
Stop-WebAppPool -Name $siteName;
}
if($siteState -eq "Started" -or $poolState -eq "Started"){
Start-Sleep -s 5;
}
$currentRetry = $currentRetry + 1;
}while ($siteState -eq "Started" -and $currentRetry -le 20)
Write-Host $siteName " Durdu (" $currentRetry "sn)";
Write-Host "Uygulama guncelleniyor...";
$from = "C:\WebSites\akifsite.com\_New\Api\*"
$to = "C:\WebSites\akifsite.com\_Current\Api\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host "Uygulama guncellendi";
Write-Host $siteName " calistiriliyor.."
if($siteState -eq "Stopped"){
Start-Website $siteName;
}
if($poolState -eq "Stopped"){
Start-WebAppPool -Name $siteName;
}
Write-Host $siteName " calisiyor"
Write-Host "Bitti"
Read-Host
UiUpdate
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
Write-Host "Yedekleniyor...";
$from = "C:\WebSites\akifsite.com\_Current\*"
$to = "C:\WebSites\akifsite.com\_Old\"+(get-date).ToString('yyyy_MM_dd-hh_mm_ss')+"\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host $to " klasorune yedeklendi";
$siteName = "akifsite.com"; #poolState name aynı diye bunu kullanıyorum, farklı olsa poolName eklemek lazım - akif 30.09.2020
$poolState="";
$siteState ="";
$currentRetry = 0;
Write-Host $siteName " durduruluyor...";
do{
$siteState = (Get-WebsiteState $siteName).Value;
$poolState = (Get-WebAppPoolState $siteName).Value
if($siteState -eq "Started"){
STOP-Website $siteName;
}
if($poolState -eq "Started"){
Stop-WebAppPool -Name $siteName;
}
if($siteState -eq "Started" -or $poolState -eq "Started"){
Start-Sleep -s 5;
}
$currentRetry = $currentRetry + 1;
}while ($siteState -eq "Started" -and $currentRetry -le 20)
Write-Host $siteName " Durdu (" $currentRetry "sn)";
Get-ChildItem "C:\WebSites\akifsite.com\_Current" -Exclude api,web.config | Remove-Item -Recurse; #api uygulamsı ve config ayarları olduğu için onları silmiyoruz
Write-Host "Uygulama guncelleniyor...";
$from = "C:\WebSites\akifsite.com\_New\ui\*"
$to = "C:\WebSites\akifsite.com\_Current\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host "Uygulama guncellendi";
Write-Host $siteName " calistiriliyor.."
if($siteState -eq "Stopped"){
Start-Website $siteName;
}
if($poolState -eq "Stopped"){
Start-WebAppPool -Name $siteName;
}
Write-Host $siteName " calisiyor"
Write-Host "Bitti"
Read-Host
24 Eylül 2020 Perşembe
IIS HTTPS Yönlendirme - ReWrite
<system.webServer>
<rewrite>
<rules>
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
17 Eylül 2020 Perşembe
IIS Üzerinde Ücretsiz SSL alma (90 günlük) sslforfree
https://manage.sslforfree.com/certificate/new sayfasından sihirbazı izleyip domain onayını aldıktan sonra indirme yapıyoruz.Domain onayı almak için "/.well-known/pki-validation/{key}" altında bir doğrulama dosyası isteyecek. Bunun için uygulama altına Virtual Directory açmamız gerekiyor ".well-known" sanal yolunu "C:\VirtualDirectory\well-known" yapabilirsin kafana göre. Sonra onay çin gerekli dosyayı istediği yola atıp onaylaman gerekiyor.
https://decoder.link/converter adresinden tamamlanacak olan sertifikayı convert ediyoruz
ca_bundle.crt
Certificate File to Convert = certificate.crt
Chain Certificate File (optional) Private Key File= private.key
Type To Convert To = PFX/PKCS#12
PFX Password = (Boş bırakılabilir)
seçiyoruz, convert dediğimizde "certificate.pfx" adında bir dosya oluşturacak. Bunu IIS üzerinde SSL Sertifikaları bölümünden "Complete Certificate Request" veya "Sertifika İsteğini Tamamla" diyip, sertifikaya akılda kalıcı bir isim verdikten sonra işlemi tamamlıyorsunuz. Artık uygulamanızın bindings kısmında 443 olan https domainin SSL certificate'ini yüklediğiniz sertifikayı atayabilirsiniz.
Angular + .Net Core Uygulamayı IIS üzerinde aynı site üzerinde yayınlama
IIS üzerinde
angular-site.com site açılır. Add Aplication'dan aynı dizin içine "Api" klasörü seçilir. Buraya .Net Core Uygulama atılır. Daha sonra Angular uygulamada terminale
ng build --prod
yazılıp build alınır. dist klasörüne çıkan angular-site klasörü içindeki dosyalar IIS üzerindeki angular-site.com sitesinin ana dizinine kopyalanır. Angular uygulamanın web.config aşağıdaki gibi olmalıdır. (iis rewrite eklentisini kurmak gerekiyor).
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="api/" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Dikkat edilmesi gereken satır
<add input="{REQUEST_URI}" pattern="api/" negate="true" />
yani diyoruz ki http isteklerinde api/ ile başlayanları angulara yönlendirme bu sayede api klasörü altındaki .Net Core uygulamaya gidiyor.
Peki bunu neden yaptık? normalde angular-site.com ve api.angular-site.com şeklinde 2 uygulamayı aynı iis üzerinde yayınlamak istedik. Uygulama içinde konum almak gerektiği ve angular içinde apiye istek gittiği için iki uygulamada https olması gerekiyordu. https://manage.sslforfree.com üzerinden aldığım free ssl'ler aynı anda 1 tanesi kullanılabildiği için işime yaramadı, wildcards almadığımız için uygulama patladı. Bu yüzden aynı uygulama içinde birleştirip 1 ssl ile işimizi gördük
.net 6 mapget kullanımı
app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { var response = JsonConvert.Seriali...
-
Komut ekranına aşagıdaki komutları yazarak windows service işlemlerini gerçekleştirebiliriz. Not : Komut ekranı (Başlat -> Çalıştır -...
-
COMMAND PROMPT TEMEL VE İLERİ DÜZEY ANLATIM Command Prompt komutlarını anlatmaya başlamadan önce, MS-DOS komut türlerine değinelim. Komut...
-
(3)BİN (6)MİLYON (9)MİLYAR (12)TRİLYON (15)KATRİLYON (18)KENTİLYON (21)SEKSİLYON (24)SEPTİLYON (27)OKTİLYON (30)NONİLYON (33)DESİL...