locked
How to get Core 2.1 Cookies Consent Message to Display RRS feed

  • Question

  • User248267340 posted

    I started learning Core 2.1, and made use of the partial view for Cookies Consent. Things went well.

    Then I changed the bootstrap file from v. 3 to v.4, and the consent message looks wonky. The navbar

    collapses by default, the button is now a tiny 4 pixel barline, and the entire navbar is unformatted.

    Has anyone come across this and fixed it? What did you do?

    I'd be grateful for any advice on how to fix this. All my code is auto-generated. Only bootstrap changed.

    Friday, April 24, 2020 12:07 AM

Answers

  • User711641945 posted

    Hi coreysan,

    For asp.net core 2.1,it uses bootstrap v3.And for asp.net core 2.2,it uses bootstrap v4.

    I think the fastest way is to create a project with asp.net core 2.2.Then copy the whole Index.cshtml and _Layout.cshtml.And for 2.2,it does not contain the _CookieConsentPartial in Layout,you could add by yourself.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 27, 2020 9:40 AM

All replies

  • User711641945 posted

    Hi coreysan,

    You could create a project and see the difference between bootstrap v4 and v3,change like below:

    <nav class="navbar  navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div class="container">
                <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">TestProject</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="navbar-collapse collapse">
                    <ul class="navbar-nav flex-grow-1">
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    
        <partial name="_CookieConsentPartial" />
    
        <div class="container body-content">
            @RenderBody()
            <hr />
            <footer>
                <p>&copy; 2020 - TestProject</p>
            </footer>
        </div>

    Best Regards,

    Rena

    Friday, April 24, 2020 8:42 AM
  • User248267340 posted

    Hi Rena! Thanks for working with me on this.

    I copied your code exactly, and ran with borrstrap 3.0.3, and also for 4.3.1.

    Both look awful.

    Version 3 shows the consent dialog and buttons at the top, but then corrupts the nav bar by inserting a little gray bar about 4-5 pixels high.

    Version 4 is worse. It doesn't show any dialog because the default project slideshow covers it up. It also shows the tiny gray bar.

    Maybe if I just redesign the whole thing? What would you do?

    Friday, April 24, 2020 10:45 PM
  • User711641945 posted

    Hi coreysan,

    For asp.net core 2.1,it uses bootstrap v3.And for asp.net core 2.2,it uses bootstrap v4.

    I think the fastest way is to create a project with asp.net core 2.2.Then copy the whole Index.cshtml and _Layout.cshtml.And for 2.2,it does not contain the _CookieConsentPartial in Layout,you could add by yourself.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 27, 2020 9:40 AM
  • User248267340 posted

    Rena,

    Thanks so much for your help! This discussion motivated me to look for alternate code, and I found the right layout in MSDN.

    It's just a reduced partial view and works much, much better!

    Thanks for pushing me!

    Corey

    Monday, April 27, 2020 4:01 PM