Image for post
Image for post

Usually downloading packages has been pain over corporate networks. One way is to switch to personal network now and then to download packages.
Here is a work around for this, use any proxy server providing your credentials. But thing is everytime I change my password I break my head to finally realize the packages are not downloading because of the old credentials in the proxy settings. This is how I get around this, using Fiddler.

Once you have downloaded fiddler, open fiddler and then under rules menu check `Automatically Authenticate`

CORS — Cross Origin Resource Sharing, basically helps our application from Cross site scripting attacks. This will restrict a website from access or sending data to another origin( web app).

Image for post
Image for post
Photo by Banter Snaps on Unsplash

This post will help look into enabling CORS in dotnet core application. Every POST request before posting the actual requests will send an [Preflighted requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Preflighted_requests) using the OPTION method like the below sample.

OPTIONS {{apiendpoint}}/api/web/incoming HTTP/1.1

Access-Control-Request-Method: POST

Origin: http://localhost:4200

This is to check if the actual request method in this case POST is allowed or not.

So to enable this in dotnet core we use AddCors of the IServiceCollection in StartUp.cs

Image for post
Image for post

With Chrome 64 you can enable dark theme.

Right Click on chrome shortcut then click on properties and set the target to

”C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” — force-dark-mode

Restart the browser and there you go the dark side 😜

— force-dark-mode

— Photo by James Pond on Unsplash

— Originally posted on Bitsmonkey

Image for post
Image for post
-Photo by Burak K from Pexels

When working with external API’s, testing application with mock request was one way. So when I want to test with a live API I was forced to host it on public (Not really!). One easy solution to this is using [ngrok](https://ngrok.com/) which basically is a Tunneling/Port forwarding software which has such an humble setup.

All we have to do is Download-->run ngrok http 5000. That’s it!!

All we did was exposed port 5000 over http to the outside. Once you run the command it would create an enpoint for the outside world (internet) which would look someting like this

http://9e844545.ngrok.io

It can do more than that. To find out more probably you can dig through these docs to start with.

Now that you have an endpoint to share to the outside worldwe can use this URL and set webhooks to this.

-Originally posted on Bitsmonkey

Image for post
Image for post

One of the ways to secure the API’s is using JWT. This is how it works, We will create a controller with an AllowAnonymous action. Make sure you have Authorize attribute over all of your controllers otherwise you have a potential loophole dangling in there.

Image for post
Image for post
Photo by Braydon Anderson on Unsplash

The least we can to do when browsing using chrome is use incognito mode. So here is way to always open chrome in incognito mode use this argument for the application shortcut.

--incognito

Open the properties of application shortcut and change as below

Accidentally pushing sensitive data stored in application config into source controls!!! Thankfully this happens to many not only you ;-). It feels good when you have company doing mistakes or anything else.

Image for post
Image for post

So here is how make sure this does not happen again. There are multiple ways to protect, the one we will learn now is using Secret Manager tool in #dotnetcore.

All we have to do use dotnet user-secrets this command. Before using it remove the sensitive value of the property you are trying to hide.

In my case it is ”TwilioAuthToken”:”” in appsettings.json file.

Now in the terminal run this below…

Here is how we containerize an application in this example I have chosen a dotnetcore application.

Image for post
Image for post

Add a Dockerfile which will be used to create an image for your application. Below is the sample.

FROM microsoft/dotnet:2.2-sdk AS build this basically says create our application based on this Microsoft image.

Navigate the shell to your application folder and then using docker run create an image for your application.

docker build -t sampleapp.

you can see your image using docker images. Finally that you have your image ready we can create as many container we need using this.

There are two options to create a container out of the image you just created either use this below…

To use VSCode for .net core you would need Omnisharp extension so that we can debug our application just like as in Visual Studio.

Image for post
Image for post
Photo by SpaceX on Unsplash

Using the dotnet new command we create a web and an API project

dotnet new webapp appname.web
dotnet new webapi appname.api

Create a solution so that it wraps all the projects in one place

dotnet new sln appname
dotnet sln add appname.web appname.api

After building the Web and the API projects we need to create the launch.json which VScode refers to build and debug the application. …

When developing a web application we separate our application with *.web being initial server-side application and we provide a *.api application which will help us fetch/update data for client-side operations and avoid page reloads.

Image for post
Image for post
Photo by Vincent van Zalinge on Unsplash

Here is a .NET Core application I was working on which had a similar kind of ask, and I wanted to use VSCode to debug my application.

This is how we do it, first, we need to create a solution so that we keep both the API and Web project in one place

dotnet new sln -n appname

dotnet sln add src/appname/appname.web.csproj

dotnet sln add src/appname/apname.api.csproj

Open “launch.json” …

bitsmonkey

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store