How to fix context cannot be declared Issue with configuring CookiePolicyOptions in startup.cs?What is a NullReferenceException, and how do I fix it?Dependency injection failure in ASP.NET Core RC2Unable to find Use.RunTimePageInfo() method in startup.cs file in aspnet coreHow do I dynamically choose a connection string based on Environment in .Net Core startup?Can authentication cookie be shared between two .Net Core 2.0 applications?Can't get my Asp.Net Core project to work published to folder on localhostInvalidOperationException: Cannot resolve scoped serviceFailed to load http://localhost:5000/.well-known/openid-configuration: No 'Access-Control-Allow-Origin' header is present on the requested resourceGet client IP and compare values with the configurationforce innodb engine with Pomelo.EntityFrameworkCore.MySql 2.1.4

Could Apollo astronauts see city lights from the moon?

How can this Stack Exchange site have an animated favicon?

Two trains move towards each other, a bird moves between them. How many trips can the bird make?

Can an integer optimization problem be convex?

Writing a letter of recommendation for a mediocre student

Is there a way to hide HTML source code yet keeping it effective?

Safe to use 220V electric clothes dryer when building has been bridged down to 110V?

Extruding snaps back

Basic digital RC approximation filter in python (Micropython)

What is the meaning of "heutig" in this sentence?

Is there a difference between equality and identity?

How to justify a team increase when the team is doing good?

Reorder a matrix, twice

Is it impolite to ask for halal food when traveling to and in Thailand?

12TET vs Pythagorean scales; "perfect" fourths?

1, 2, 4, 8, 16, ... 33?

Safely hang a mirror that does not have hooks

Strange Sticky Substance on Digital Camera

Do we know the situation in Britain before Sealion (summer 1940)?

What secular civic space would pioneers build for small frontier towns?

Order of ingredients when making Pizza dough

Do we have any particular tonal center in mind when we are NOT listening music?

Why does NASA publish all the results/data it gets?

What benefits does the Power Word Kill spell have?



How to fix context cannot be declared Issue with configuring CookiePolicyOptions in startup.cs?


What is a NullReferenceException, and how do I fix it?Dependency injection failure in ASP.NET Core RC2Unable to find Use.RunTimePageInfo() method in startup.cs file in aspnet coreHow do I dynamically choose a connection string based on Environment in .Net Core startup?Can authentication cookie be shared between two .Net Core 2.0 applications?Can't get my Asp.Net Core project to work published to folder on localhostInvalidOperationException: Cannot resolve scoped serviceFailed to load http://localhost:5000/.well-known/openid-configuration: No 'Access-Control-Allow-Origin' header is present on the requested resourceGet client IP and compare values with the configurationforce innodb engine with Pomelo.EntityFrameworkCore.MySql 2.1.4






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm trying to configure Startup.cs file to comform with https://docs.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.2 but I'm getting error in options.CheckConsentNeeded = context => true; The error is as follows: "A local parameter named 'context' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter"



Below is my Sturtup.cs fragment



public class Startup
{
private readonly IHostingEnvironment _env;
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration, IHostingEnvironment env)

_env = env;
_configuration = configuration;



// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>

options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddJsonOptions(options =>
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
); ...


Does anybody encountered this issue? I was looking for solving to this, but without success. Every hint will be very helpful.










share|improve this question



















  • 3





    try changing 'context' to another name

    – João Paulo Amorim
    Mar 28 at 17:03











  • Wow that works. Can you explain why I can't use "context"? Thank you very much for help!

    – Michal16511
    Mar 28 at 18:59






  • 1





    you already had the answer in the question ''context' cannot be declared in this scope because that name is used in an enclosing local scope', this name is protected local variable, it is used for some reason by .net, so you can't put the same name as the local variable

    – João Paulo Amorim
    Mar 28 at 19:03











  • @JoãoPauloAmorim Thank you very much once again for clarification!

    – Michal16511
    Mar 28 at 19:14











  • glad to help ! :D

    – João Paulo Amorim
    Mar 28 at 19:33

















0















I'm trying to configure Startup.cs file to comform with https://docs.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.2 but I'm getting error in options.CheckConsentNeeded = context => true; The error is as follows: "A local parameter named 'context' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter"



Below is my Sturtup.cs fragment



public class Startup
{
private readonly IHostingEnvironment _env;
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration, IHostingEnvironment env)

_env = env;
_configuration = configuration;



// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>

options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddJsonOptions(options =>
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
); ...


Does anybody encountered this issue? I was looking for solving to this, but without success. Every hint will be very helpful.










share|improve this question



















  • 3





    try changing 'context' to another name

    – João Paulo Amorim
    Mar 28 at 17:03











  • Wow that works. Can you explain why I can't use "context"? Thank you very much for help!

    – Michal16511
    Mar 28 at 18:59






  • 1





    you already had the answer in the question ''context' cannot be declared in this scope because that name is used in an enclosing local scope', this name is protected local variable, it is used for some reason by .net, so you can't put the same name as the local variable

    – João Paulo Amorim
    Mar 28 at 19:03











  • @JoãoPauloAmorim Thank you very much once again for clarification!

    – Michal16511
    Mar 28 at 19:14











  • glad to help ! :D

    – João Paulo Amorim
    Mar 28 at 19:33













0












0








0








I'm trying to configure Startup.cs file to comform with https://docs.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.2 but I'm getting error in options.CheckConsentNeeded = context => true; The error is as follows: "A local parameter named 'context' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter"



Below is my Sturtup.cs fragment



public class Startup
{
private readonly IHostingEnvironment _env;
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration, IHostingEnvironment env)

_env = env;
_configuration = configuration;



// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>

options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddJsonOptions(options =>
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
); ...


Does anybody encountered this issue? I was looking for solving to this, but without success. Every hint will be very helpful.










share|improve this question














I'm trying to configure Startup.cs file to comform with https://docs.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.2 but I'm getting error in options.CheckConsentNeeded = context => true; The error is as follows: "A local parameter named 'context' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter"



Below is my Sturtup.cs fragment



public class Startup
{
private readonly IHostingEnvironment _env;
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration, IHostingEnvironment env)

_env = env;
_configuration = configuration;



// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>

options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddJsonOptions(options =>
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
); ...


Does anybody encountered this issue? I was looking for solving to this, but without success. Every hint will be very helpful.







c# asp.net-core cookies asp.net-core-2.2 asp.net-authorization






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 17:02









Michal16511Michal16511

293 bronze badges




293 bronze badges










  • 3





    try changing 'context' to another name

    – João Paulo Amorim
    Mar 28 at 17:03











  • Wow that works. Can you explain why I can't use "context"? Thank you very much for help!

    – Michal16511
    Mar 28 at 18:59






  • 1





    you already had the answer in the question ''context' cannot be declared in this scope because that name is used in an enclosing local scope', this name is protected local variable, it is used for some reason by .net, so you can't put the same name as the local variable

    – João Paulo Amorim
    Mar 28 at 19:03











  • @JoãoPauloAmorim Thank you very much once again for clarification!

    – Michal16511
    Mar 28 at 19:14











  • glad to help ! :D

    – João Paulo Amorim
    Mar 28 at 19:33












  • 3





    try changing 'context' to another name

    – João Paulo Amorim
    Mar 28 at 17:03











  • Wow that works. Can you explain why I can't use "context"? Thank you very much for help!

    – Michal16511
    Mar 28 at 18:59






  • 1





    you already had the answer in the question ''context' cannot be declared in this scope because that name is used in an enclosing local scope', this name is protected local variable, it is used for some reason by .net, so you can't put the same name as the local variable

    – João Paulo Amorim
    Mar 28 at 19:03











  • @JoãoPauloAmorim Thank you very much once again for clarification!

    – Michal16511
    Mar 28 at 19:14











  • glad to help ! :D

    – João Paulo Amorim
    Mar 28 at 19:33







3




3





try changing 'context' to another name

– João Paulo Amorim
Mar 28 at 17:03





try changing 'context' to another name

– João Paulo Amorim
Mar 28 at 17:03













Wow that works. Can you explain why I can't use "context"? Thank you very much for help!

– Michal16511
Mar 28 at 18:59





Wow that works. Can you explain why I can't use "context"? Thank you very much for help!

– Michal16511
Mar 28 at 18:59




1




1





you already had the answer in the question ''context' cannot be declared in this scope because that name is used in an enclosing local scope', this name is protected local variable, it is used for some reason by .net, so you can't put the same name as the local variable

– João Paulo Amorim
Mar 28 at 19:03





you already had the answer in the question ''context' cannot be declared in this scope because that name is used in an enclosing local scope', this name is protected local variable, it is used for some reason by .net, so you can't put the same name as the local variable

– João Paulo Amorim
Mar 28 at 19:03













@JoãoPauloAmorim Thank you very much once again for clarification!

– Michal16511
Mar 28 at 19:14





@JoãoPauloAmorim Thank you very much once again for clarification!

– Michal16511
Mar 28 at 19:14













glad to help ! :D

– João Paulo Amorim
Mar 28 at 19:33





glad to help ! :D

– João Paulo Amorim
Mar 28 at 19:33












0






active

oldest

votes














Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403198%2fhow-to-fix-context-cannot-be-declared-issue-with-configuring-cookiepolicyoptions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403198%2fhow-to-fix-context-cannot-be-declared-issue-with-configuring-cookiepolicyoptions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript