Saturday, February 23, 2019

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy.

Solution: Make sure that the url configured in angular (usually in environment.ts file missing http or https). Example below:


Error Configuration:
export const environment = {
  production: false,
  apiUrl: 'localhost:56425/api'
};

Correct configuration:

export const environment = {
  production: false,
  apiUrl: 'http://localhost:56425/api'

};




Monday, August 20, 2018

Generate SQL Scripts for the Migration - .Net Core Entity FrameWork


Script-Migration command helps to generate the SQL Scripts (for code first model) that can be run directly from SQL Server Management Studio

Syntax:

SYNTAX
    Script-Migration [-From] <String> [-To] <String> [-Idempotent] [-Context <String>] [-Environment <String>] [-Project <String>] [-StartupProject <String>] [<CommonParameters>]


Example:

Script-Migration -from "20180523175151_InsertComponentType" -to "20180604012237_OPIDTableInsert"

Thursday, January 11, 2018

Get All Timer Jobs Status from a Farm in GridView using PowerShell


clear
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

function Get-SPTimerJobStatus
{
    Get-SPTimerJob | sort Name | ForEach-Object {
        $lastRun = $_.HistoryEntries | Select-Object -first 1
        if ($_.WebApplication -eq $null) { $level = "Farm" }
        else { $level = $_.WebApplication.Url }
        
        $values = @{
            "Name" = $_.Name
            "Level" = $level
            "StartTime" = $lastRun.StartTime
            "EndTime" = $lastRun.EndTime
            "Status" = $lastRun.Status
        }
        New-Object PSObject -Property $values | Select @("Name","Level","StartTime","EndTime","Status")
    }
}
Get-SPTimerJobStatus | Out-GridView

Find out all Site Collection Administrators from a Web Application using PowerShell


clear
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

############### VARIABLES ################################

$rootsiteUrl = "https:/webappurl"

################################################################

$rootSite = New-Object Microsoft.SharePoint.SPSite($rootsiteUrl)
$spWebApp = $rootSite.WebApplication
 
foreach($site in $spWebApp.Sites)
{
    foreach($siteAdmin in $site.RootWeb.SiteAdministrators)
    {
        Write-Host "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.DisplayName)"
    }
    $site.Dispose()
}
$rootSite.Dispose()

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy. Solution: Make sure that the...