Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 6 > BOOK: Professional C# 6 and .NET Core 1.0
|
BOOK: Professional C# 6 and .NET Core 1.0
This is the forum to discuss the Wrox book Professional C# 6 and .NET Core 1.0 by Christian Nagel; ISBN: 978-1-119-09660-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C# 6 and .NET Core 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2016, 10:58 AM
Authorized User
 
Join Date: Aug 2016
Posts: 11
Thanks: 0
Thanked 2 Times in 2 Posts
Default Chapt 40: pg1248-1249 - SessionState

When I run the example I get this in the browser:

Unable to resolve service for type 'Microsoft.AspNetCore.DataProtection.IDataProtecti onProvider' while attempting to activate 'Microsoft.AspNetCore.Session.SessionMiddleware'.

I found the fix here:
https://forums.asp.net/t/2097262.asp...on+not+working

1) Add in your project.json as below
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.Extensions.Caching.Memory": "1.0.0",

2)In your ConfigureServices method of Startup.cs
services.AddMemoryCache();
services.AddSession()

-----------------------------------

Also, after I get to "Configure ASP.Net" on p 1249, and add the appsettings.json and the StartUp constructor, I start getting this error:
"Unable to resolve service for type 'Microsoft.Extensions.Caching.Distributed.IDistrib utedCache' while attempting to activate 'Microsoft.AspNetCore.Session.DistributedSessionSt ore'."

I found a resolution at:
https://docs.microsoft.com/en-us/asp...tals/app-state
services.AddMemoryCache();
from step 2 above
with
services.AddDistributedMemoryCache();

I'll have to read more about State now;.
Looks like a lot of changes:
No more Application replaced with Cache, and so on.

Just replace:

Last edited by smiller781; December 23rd, 2016 at 12:15 PM..
 
Old January 3rd, 2017, 06:49 AM
Wrox Author
 
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

Thanks for the note. The code download was already updated, but I missed adding the information to the book updates.

Updated information added here:
https://github.com/ProfessionalCShar...BookUpdates.md

I'm also sending an update for the Wrox errata list.

Thanks
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapt 40: pg.1240-1241 - Form Data smiller781 BOOK: Professional C# 6 and .NET Core 1.0 3 January 17th, 2017 02:36 PM
Sessionstate larsp777 BOOK: Beginning ASP.NET 4 : in C# and VB 6 September 27th, 2012 03:09 AM
SessionState Lost lpeoples BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 4 August 24th, 2010 08:02 AM
Sessionstate jgrant ASP.NET 2.0 Basics 1 August 26th, 2007 01:36 PM
Unrecognized configuration section 'sessionState' Shihanshin BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 27th, 2005 05:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.