.net-core-2.0

AutoMapper : Map both ways in Net Core 2 syntax

不羁的心 提交于 2019-12-07 10:38:27
What is syntax to map both ways in AutoMapper Net Core2? I need to map ProductViewModel and ProductDto both ways. This is not working, Startup.cs var config = new MapperConfiguration ( cfg => cfg.CreateMap<Models.ProductDto, Models.ProductViewModel>(), cfg => cfg.CreateMap<Models.ProductViewModel, Models.ProductDto>() ); var mapper = config.CreateMapper(); I'd rather create a seprate initializer and mapper. e.g here is my AutoMapperStartupTask class. public static class AutoMapperStartupTask { public static void Execute() { Mapper.Initialize( cfg => { cfg.CreateMap<ProductViewModel, ProductDto

Session Store IQueryable in HttpContext

浪尽此生 提交于 2019-12-07 08:32:24
I am migrating project from Net MVC to MVC Core 2. How do I set IQueryable in Sessions? In Net MVC it was the following, public ActionResult CurrentOwners_Read([DataSourceRequest]DataSourceRequest request, int propertyID) { if (propertyID == 0) { throw new ArgumentNullException("propertyID"); } IQueryable<PropertyOwnerRoleViewModel> allResult = (IQueryable<PropertyOwnerRoleViewModel>)HttpContext.Session.GetString(_currentOwnersResult).AsQueryable(); if (allResult == null) { PropertyOwnerManager propertyOwnerManager = new PropertyOwnerManager(); allResult = propertyOwnerManager

How to do simple header authorization in .net core 2.0?

橙三吉。 提交于 2019-12-07 06:04:33
问题 I have been unable to find information on this particular issue after the 2.0 changes to .NET Core. I have cookie authorization like this: services.AddAuthentication("ExampleCookieAuthenticationScheme") .AddCookie("ExampleCookieAuthenticationScheme", options => { options.AccessDeniedPath = "/Account/Forbidden/"; options.LoginPath = "/Account/Login/"; }); For another part (of my controllers I would like to simply authorize based on a simple header. In the examples I've found, either I am

Which C# version .NET Core uses?

北战南征 提交于 2019-12-06 16:54:19
问题 I know that C# version depends on .NET Framework. But .NET Core which version uses? Particularly .NET Core 2? C#7? 回答1: .NET Core 2.0 references Roslyn 2.3, which corresponds to Visual Studio 2017 version 15.3 and supports C# 7.1. 回答2: The C# what's new version history page gives a list of all versions plus their associated Visual Studio and .NET core version: C# 7.3 Visual Studio 2017 version 15.7, and in the .NET Core 2.1 SDK 2.1.300 RC1 C# 7.2 Visual Studio 2017 version 15.5, and in the

How to compile Typescript files on VSTS build server for .Net Core 2 projects

为君一笑 提交于 2019-12-06 07:45:23
问题 I've been trying to get my TypeScript files compiled to JavaScript files in my CI build process on VSTS. Once the JavaScript files have been generated then my gulp file process can process them to the wwwroot folder. The project builds fine in Visual Studio 2017 with VS obeying the tsconfig.json file by compiling the file on change and then the Task Runner running the gulp file on detected changes and build. All the correct files are genereated when building or publishing locally in Visual

How to hide .NET Core compatibility warnings when referencing .NET 4.6 NuGet package in VS 2017.3

浪子不回头ぞ 提交于 2019-12-06 03:02:47
问题 I'm working on a .NET Core CLI app that needs to reference a 3rd party NuGet package that has not been published with a netcoreappX.X target. I've run the Analyze Project Portability tool on it and got 100% compatibility, which is expected, as this is a relatively simple library. The problem then comes in the form of this annoying NuGet warning: Warning: NU1701 Package 'XXXXXX 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version

SmtpAppender missing in log4net 2.0.8 nuget?

柔情痞子 提交于 2019-12-05 09:17:14
I created a console app for .NET Core 2.0 and installed a log4net 2.0.8 nuget I want to use the SmtpAppender but it does not exist in the library This is my log4net configuration <?xml version="1.0" encoding="utf-8" ?> <log4net> <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> <to value="test@test.com" /> <from value="test@test.com" /> <subject type="log4net.Util.PatternString" value="Message logged" /> <smtpHost value="localhost" /> <authentication value="None" /> <port value="25" /> <bufferSize value="1" /> <lossy value="false" /> <layout type="log4net.Layout.PatternLayout

How to do simple header authorization in .net core 2.0?

无人久伴 提交于 2019-12-05 09:15:25
I have been unable to find information on this particular issue after the 2.0 changes to .NET Core. I have cookie authorization like this: services.AddAuthentication("ExampleCookieAuthenticationScheme") .AddCookie("ExampleCookieAuthenticationScheme", options => { options.AccessDeniedPath = "/Account/Forbidden/"; options.LoginPath = "/Account/Login/"; }); For another part (of my controllers I would like to simply authorize based on a simple header. In the examples I've found, either I am unable to get the headers, or they have been made only for facebook, google, cookies etc. How do I add an

Project 'ClassLibrary1.csproj' targets 'netcoreapp2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'

为君一笑 提交于 2019-12-05 02:17:36
I have two class library project with the following setting: ClassLibrary1 --> Target framework-->.NET Core 2.1 ClassLibrary2 --> Target framework-->.NET Framework 4.7.2 Now I referenced the ClassLibrary1 project in ClassLibrary2 project. It was done successfully. But on rebuilding the project I am getting an error: Severity Code Description Project File Line Suppression State Error Project '..\ClassLibrary1\ClassLibrary1.csproj' targets 'netcoreapp2.1'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'. ClassLibrary2 Can anyone help me to know the reason for

Blazor: Implementing 404 not found page

血红的双手。 提交于 2019-12-05 01:34:26
问题 I'd like to implement a page internal to my application that appears when the blazor router is unable to find a matching route. Currently, all requests are routing to index.html so I'm unable to handle errors through iis as I may normally. If I enter an invalid route, I will be shown a blank page (which is actually index.html ) and receive a console error: 'Router' cannot find any component with a route for '/some/Nonexistent/Route'. It seems like I should be able to handle this since the