Posts

Showing posts from December, 2017

ASPNETCORE_ENVIRONMENT in Published Project

Typical Program.cs         public Startup(IHostingEnvironment env)         {             // https://blog.elmah.io/config-transformations-in-aspnetcore/             // https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/             // https://github.com/aspnet/Hosting/issues/863             // For dev, please remove or rename appsettings.production.json, so that it's not used             var builder = new ConfigurationBuilder()                 .SetBasePath(env.ContentRootPath)                 .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)                 .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)                 .AddEnvironmentVariables();             Configuration = builder.Build();         } Please note: ASPNETCORE_ENVIRONMENT settings in Properties\launchSettings.json only affects debugging by using Visual Studio or C:\projectfolder>dotnet

Errors in Net Core Add-Migration

Visual Studio 2017 version 15.5.2, Net Core 2. Add-Migration error: Exception calling "SetData" with "2" argument(s): "Type  'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in  assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=15.0.0.0,  Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\wanj\.nuget\packages\entityframework\6.2.0\tools\EntityFramework.psm1:720 char:5 +     $domain.SetData('project', $project) +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException     + FullyQualifiedErrorId : SerializationException Exception calling "SetData" with "2" argument(s): "Type  'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in  assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Impl

Set up Visual Studio 2017 for .Net Core Application Development

Image
The Default Profile setting in LibPrograms/Properties/LaunchSettings.json {   "iisSettings": {     "windowsAuthentication": true,     "anonymousAuthentication": true,     "iis": {       "applicationUrl": "http://localhost:8000",       "sslPort": 0     },     "iisExpress": {       "applicationUrl": "http://localhost:49497/",       "sslPort": 0     }   },   "profiles": {     "IIS": {       "commandName": "IIS",       "launchBrowser": true,       "environmentVariables": {         "ASPNETCORE_ENVIRONMENT": "Development"       }     },     "IISExpress": {       "commandName": "IIS",       "launchBrowser": true,       "environmentVariables": {         "ASPNETCORE_ENVIRONMENT": "Developme

Use Windows Authentication in Net Core 2.0

This link has everything we need:  Configure Windows authentication in an ASP.NET Core app About the launchsetting.json file See What is launchsetting.json in ASP.NET Core Windows Authentication and Anonymous Authentication can be set through IIS Authorization or launchsetting.json. However launchsetting.json only affects  development time (running through IIS profile) . Once deployed,  it's determined by IIS Authorization setting only. If Windows Authentication is enabled but Anonymous is disabled When Windows authentication is enabled and anonymous access is disabled, the [Authorize] and [AllowAnonymous] attributes have no effect. The above description in  Configure Windows authentication in an ASP.NET Core app  is somehow wrong. In contrast, in a Intranet app where anonymous is disabled, there is no problem to still use [Authorize] to control access based on Windows groups. This pattern is common in real world. Be aware cache issue when testing

Import SQL Server 2016 and Excel Data into SQL Server 2008 R2

Background Development    SQL Server 2016 (“2016”) Database: LibDB     Branch table: (prod data)     Category table: (prod data)     Program table: (fake data) Production SQL Server 2008 R2 (“R2”) Excel Sheet: needs to be imported into Production’s Program table Import 2016 Database into R2 Please note: R2 doesn’t recognized the database backup generated by 2016 Script to Create Database Schema (DB and All Table Structures) 2016 SMS/ LibDB/Tasks/Generate Scripts/ Next /Script entire database and all database objects/ Next /Advanced:     Script for Server Version: SQL Server 2008 R2     Types of data to script: Schema only /OK Run the script on R2 There will be errors in database creation when running this script on R2. Please replace the error lines with similar database creation statements that are generated on R2 itself. Script to Insert Data for Branch and Category Table 2016 SMS/ LibDB/Tasks/Generate Scripts/next/Select specific database objec