1. Added _CookieConsentPartial.cshtml file for cookie privacy policy consent
2. Used "_CookieConsentPartial" partial page into Layout page to support GDPR Cookie private policy
This commit is contained in:
		
							parent
							
								
									ac8fdabe5d
								
							
						
					
					
						commit
						69e91a5ba7
					
				
							
								
								
									
										41
									
								
								src/Web/WebMVC/Views/Shared/_CookieConsentPartial.cshtml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/Web/WebMVC/Views/Shared/_CookieConsentPartial.cshtml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					@using Microsoft.AspNetCore.Http.Features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@{
 | 
				
			||||||
 | 
					    var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
 | 
				
			||||||
 | 
					    var showBanner = !consentFeature?.CanTrack ?? false;
 | 
				
			||||||
 | 
					    var cookieString = consentFeature?.CreateConsentCookie();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@if (showBanner)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    <nav id="cookieConsent" class="navbar navbar-default navbar-fixed-top" role="alert">
 | 
				
			||||||
 | 
					        <div class="container">
 | 
				
			||||||
 | 
					            <div class="navbar-header">
 | 
				
			||||||
 | 
					                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#cookieConsent .navbar-collapse">
 | 
				
			||||||
 | 
					                    <span class="sr-only">Toggle cookie consent banner</span>
 | 
				
			||||||
 | 
					                    <span class="icon-bar"></span>
 | 
				
			||||||
 | 
					                    <span class="icon-bar"></span>
 | 
				
			||||||
 | 
					                    <span class="icon-bar"></span>
 | 
				
			||||||
 | 
					                </button>
 | 
				
			||||||
 | 
					                <span class="navbar-brand"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></span>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class="collapse navbar-collapse">
 | 
				
			||||||
 | 
					                <p class="navbar-text">
 | 
				
			||||||
 | 
					                    Use this space to summarize your privacy and cookie use policy.
 | 
				
			||||||
 | 
					                </p>
 | 
				
			||||||
 | 
					                <div class="navbar-right">
 | 
				
			||||||
 | 
					                    <a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Learn More</a>
 | 
				
			||||||
 | 
					                    <button type="button" class="btn btn-default navbar-btn" data-cookie-string="@cookieString">Accept</button>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </nav>
 | 
				
			||||||
 | 
					    <script>
 | 
				
			||||||
 | 
					        (function () {
 | 
				
			||||||
 | 
					            document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
 | 
				
			||||||
 | 
					                document.cookie = el.target.dataset.cookieString;
 | 
				
			||||||
 | 
					                document.querySelector("#cookieConsent").classList.add("hidden");
 | 
				
			||||||
 | 
					            }, false);
 | 
				
			||||||
 | 
					        })();
 | 
				
			||||||
 | 
					    </script>
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -49,6 +49,7 @@
 | 
				
			|||||||
		</div>
 | 
							</div>
 | 
				
			||||||
	</header>
 | 
						</header>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<partial name="_CookieConsentPartial" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@RenderBody()
 | 
						@RenderBody()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user