Posts

Showing posts from September, 2020

Enable Windows Authentication between Angular and ASPNet WebAPI

--- --- How to enable Windows credentials between Angular and ASPNET WebAPI Create the WebAPI with windows authentication enabled You might need to enable CORS In your http calls of your Angular app, send a request options object, in this object, set withCredentials = true import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; @ Injectable ( { providedIn : 'root' } ) export class ItemsService { constructor ( private httpClient : HttpClient ) { } getItems = ( ) => { return this . httpClient . get ( 'http://localhost:49288/api/items' , { withCredentials : true } ) ; } } In your WebAPI service, one way to get the current user is: public class ItemsController : ApiController { public string Get ( ) { return User . Identity . Name ; } } Resources https://stackoverflow.com/a/36506031/3596441

How to enable CORS between an Angular app and an ASP.Net Web API Service

Image
How to enable CORS between an Angular app and an ASP.Net Web API Service If you have an ASP Net WebAPI service running in one domain, and an angular app running in another domain, you’ll need to enable CORS in the web service, in this example, we’re also enabling Windows authentication Works for NET Framework 4.8 Microsoft ASPNET Web API Angular CLI 10.1 Node 10.15 Windows 10 Create a .NET WebAPI application with Windows Authentication Create a folder and name it Models Inside Models create Employee.cs and this code: public class Employee { public int Id { get ; set ; } public string Name { get ; set ; } public string Email { get ; set ; } } Create the Employees controller, right click the Controllers folder and click Add Controller In the Add Scaffold window, select Web API 2 Controller - Empty In Controller Name write EmployeesController In EmployeesController.cs include this code: [ RoutePrefix ...

Angular App in Multiple Languages

Image
Angular App in Multiple Languages Angular App in Multiple Languages To Localize your app follow the i18n internationalization official guideline in the Angular website Steps Create the angular app ng new localized-app Add Internationalization (i18n) support ng add @angular/localize Add the i18n custom attribute to your text elements <h1 i18n>PLEASE TRANSLATE THIS</h1> Extract the source language file into a dedicated folder using the xi18n command ng xi18n --output-path src/locale Verify that src/locale/messages.xlf was created Create a translation file for each language: copy messages.xlf and rename the copy by using the locale-id of the targeted language, for example, “es” stands for spanish: messages.es.xlf Open messages.es.xlf with a text editor (or with a xlf editor if you have one), you will see something like this <?xml version="1.0" encoding="UTF-8" ?> < xliff version = " 1.2 " xmln...

SSIS: How to read error messages from a console app and send them by email

Image
SSIS: How to read error messages from a console app and send them by email SSIS: How to read error messages from a console app and send them by email Let’s say you have a SSIS package that runs a console app, everything works fine, but one day, the console app fails, and the SSIS package fails with a non helpful error message. You want to know what was the error, what data was involved and you want it be email Works with SSIS project in Visual Studio 2015 Simple console app in .NET 4.8 Steps Console app Create a console app for C# Replace the code in Program.cs with this: class Program { static int Main ( string [ ] args ) { try { string value = "a" ; //Output to StdOutput variable Console . WriteLine ( "Value to convert:" + value ) ; int i = int . Parse ( value ) ; return 0 ; //In console apps, normally returning 0 in...

How to add JQuery and Bootstrap to an Angular CLI project

How to add JQuery and Bootstrap to an Angular CLI project How to add JQuery and Bootstrap to an Angular CLI project Works with Angular CLI: 10.1.1 Steps Create your Angular CLI app ng new angular - app In your terminal, run npm install jquery -- save npm install @types / jquery -- save Go to tsconfig.app.json and add an entry in the “types” array { "extends" : "../tsconfig.json" , "compilerOptions" : { "outDir" : "../out-tsc/app" , "types" : [ "jquery" ] } , "exclude" : [ "test.ts" , "**/*.spec.ts" ] } Open angular.json and make sure jquery has an entry in angular.json -> scripts ... "scripts" : [ "node_modules/jquery/dist/jquery.min.js" ] ... Follow same procedure for Bootstrap, but don’t forget to add an entry to “styles” in ang...

Markdown: Link to parts inside same document

Markdown: Link to parts inside same document How to link to parts inside the same markdown document Create your Headers # This is Header 1 ## This is Header 2 ### This is Header 3 Write links like this: [For more information please see Header 1](#this-is-header-1) [Go to Header 2](#this-is-header-2) [Click to go to Header 3](#this-is-header-3) Note : just one # for all heading sizes, no space between # and anchor name, anchor tag names must be lowercase, and delimited by dashes if multi-word . This is Header 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laboru...