Uncategorized

cors for rest web api

to add support for CORS

  1. install package
    Install-Package Microsoft.AspNet.WebApi.Cors
  2. add to WebApiConfig.Register method
    config.EnableCors();
  3. To enable CORS for all Web API controllers in your application, pass an EnableCorsAttribute instance to the EnableCors method:
     var cors = new EnableCorsAttribute("www.example.com", "*", "*");

In the case you have token oauth authentication for rest web api, fix the pre-flight request cors issue:

  1. Move the code to the first line Startupapp.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
  2. REMOVE  context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); from the GrantResourceOwnerCredentials()

 

reference:

 

SharePoint

Sideloading of apps is not enabled on this site

If you are deploying a solution/ sharepoint apps to sharepoint, at some point, you will likely come across this error: “sideloading of apps is not enabled on this site”.

so with this error, you won’t be able to deploy apps to sharepoint on-premise or online. to fix this issue, we have two different approaches for on-premise and online.

  1. on-premise server with full control

Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http://sp.contoso.com

2. sharepoint online

It is 2-steps solution for sharepoint online

  1. download and install sharepoint online management shell
  2. execute the script below
#CODE STARTS HERE
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'
Write-Host 'Ready to enable Sideloading'
$siteurl = Read-Host 'Site Url'
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString 'Password'
 
$outfilepath = $siteurl -replace ':', '_' -replace '/', '_'
 
try
{
    [Microsoft.SharePoint.Client.ClientContext]$cc = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)
    [Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    $cc.Credentials = $spocreds
    $site = $cc.Site;

    $sideLoadingGuid = new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"
    $site.Features.Add($sideLoadingGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
     
    $cc.ExecuteQuery();
     
    Write-Host -ForegroundColor Green 'SideLoading feature enabled on site' $siteurl
    #Activate the Developer Site feature
}
catch
{ 
    Write-Host -ForegroundColor Red 'Error encountered when trying to enable SideLoading feature' $siteurl, ':' $Error[0].ToString();
}

#CODE ENDS HERE

Run the code as shown below, enter the site url with username nad password for your sharepoint online, the powershell will take care of the rest for you.

enable-sideloading-sharepoint-online_thumb

Uncategorized

VS 2015 Package Manager Console Failed

Opening package manager console produce the error message:

“Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Unrestricted. Type “Get-ExecutionPolicy -List” to view your execution policy settings. For more information please see “Get-Help Set-ExecutionPolicy”.”

A temp fix is update the regedit

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell]
"ExecutionPolicy" set to empty

Restart the VS 2015 should fix this issue
Uncategorized

How to make AJAX Call from POSTMAN

There are two types of RESTful Web Service methods can be consumed by ajax call: HttpPost and HttpGet.

for HttpGet, it’s pretty simple, all we need to do is add querystring parameters to the URL.

for HttpPost, if the Rest web service method take an object as parameter, we will need to construct the object as JSON and pass it in the body of the request. A key element to get it working is to add Content-Type: application/json to HEADER section.

Uncategorized

Do NOT check Email first thing in the morning

Ignorance is Productive

When it comes to email, ignorance is bliss. That’s why if you’ve got something important you want to make progress on, I have these four words for you:

Don’t Check Your Email

as soon as you get up, work on something important for 30-45 minutes, and only then check it. If you can stand it, wait even longer.

And you know what? As long as you’re ignorant of everything else that’s going on outside, you can concentrate on what you want to work on.

Any new information you get can cause you to get distracted. On a quick tangent, this is also why I often don’t look at any news in the morning, don’t turn on the TV, and listen to audiobooks or even educational podcasts instead of the radio in my car – I don’t want anything to distract me. I can’t control everything but I can control my own.

It’s not Your Todo List

Do you know what is most important for you to work on? Do you know the first thing you want to do this morning? Then go ahead and do it!

On the other hand by checking email, you risk doing what someone else wants you to do. Every time you open an Email, you should consider whether it’s more important than everything else on your task list – but realistically, how many of us actually do that?

If you don’t, then the items you end up working on (even if it’s just replying and giving information) end up being tasks for other people rather than yourself.

Or more bluntly, when you check your inbox, the emails you get are a todo list someone else makes for you.

So, Who is in charge of your time – you, or the person emailing you?

It’s an excuse to Lack Direction

“Why are you checking email first thing in the morning anyway?”

Most likely the answer could be “you don’t know what you are supposed to be working on”

I am certainly not immune to this myself. If I am checking my inbox too often, that’s frequently an early warning sign that my todo list has gotten off track somewhere.

The real problem behind this behavior is that you don’t see checking email as a low priority activity, because you haven’t decided what the high priority activities area are. when you don’t have a clear list of priorities, checking email becomes an urgent activity that you do, but at the expense of your important ones.

If this strikes a nerve with you, don’t worry – it can be fixed. Find out Urgent versus Important time management matrix, and stop checking email so frequently.

Reaction or “Proaction”

when you check your email, the best case scenario is you checked at exactly the right moment, just when a super important email came in – and you can take instant action right away. How often does that actually happen? Rarely

The usual case is that, when you turn on your “check email” mode, you end up with more work to do, by replying emails regardless of their true priority.

I prefer taking proactive actions – what I call proaction. Work on the things that are important to you, regardless of whether they’re urgent or simply at the top of your inbox.

Searching for Excuses

If I’ blindly checking email, I am usually not checking for anything important – I am usually searching for an excuse to not do the work I know I must do.

I am searching for any reason why I can tell myself later I didn’t get the work done that needed to be.

Don’t fall in that trap. Don’t give yourself an out by checking your email for an excuse to fail.

It builds Expectation

A lot of people tell me “But I have to check my email! People expect a response from me”

First of all, I don’t believe it. If they do urgently awaiting your response, there are surly lots of ways to reach you, by phone, by visiting, by calling your colleague.

The more often you check email, the more often people will expect you to check it. and that’s the reason why people are EXPECTING response from you.

Just stop checking it first thing in the morning, and people won’t expect it anymore.

I know, it’s easier said than done. Don’t worry, after the first week or two, nobody will think anything of it.

Of course, there are causes you must check your email. well, if you do, constrain yourself to only check a limited subset of email, and I recommend you follow these rules

  1. Only check if there is something specific you are looking for or awaiting for
  2. Separate low value emails
  3. Set a time limit. Commit to checking for 5 minutes, just to look for that one piece of information, and you are done. before you open your inbox, decide what you will do if 1)the email is there 2)the email isn’t there 3)the email is incomplete. Don’t be reactionary – proactively decide what action you will take based on the outcomes you expect.

reference: http://sidsavara.com/personal-development/do-not-check-email-in-the-morning

Uncategorized

IoT: Monetizing the Internet of Things

IoT continues to evolve at a rapid pace, right in front of our very eyes. Supoposely,

  • By 2017, an estimated 90M people will live in smart homes.
  • By 2020, 50B connected devices is IoT

but there are challenges, especiallyu when it comes building a recurring revenue model that allows you to stay agile, respond to your market, and scale products quickly and successfully.

IoT is clearly the near future of business. But as we quickly progress into our increasingly digitized world, one that concentrates on connections – wireless, virtuals, etc. It’s super critical to focus on a solid business model will ensure your business gets a smart start on the right track.

the questions you have to understand and answer before you made any possible success in IoT

  1. How, if done right, IoT could mean massive growth opportunities for your business
  2. How can you successfully conquer the challenges of integrating products and services
  3. How companies like Nest, Honeywell, and Lowe’s have built powerful business models
Uncategorized

the control collection cannot be modified during databind

In SharePoint, this error appears to be a visio web access web part, or Nintex workflow issue, is due to a “detail” of the master page applied.

the master page shows the control SPWebPartManager in the HEAD insteead of the BODY.

A start point on fixing this is move the SPWebPartManager control to body part in your master page. It works for me, in the case of Nintex workflow cause the issue.

error1