Search code examples
asp.net-coreblazorrazor-pagesblazor-server-side

asp- Tags are not highlighted in Blazor server side app


I have created a new server sided blazor app with no prebuild in authentication. Now I want to implement my own authentication with a custom AppDbContext.

The database is configured so far. Now I want to create a register page. I added a Razorpage to my Pages folder named Register.cshtml. I have already added the background C# logic and now I want to create a simple register form. But I have no clue why all asp- tags are not highlighted correctly as they do in a blank Blazor app with pre configured in app authentication.

Here is my form:

<form asp-route-returnUrl="@Model.ReturnUrl" method="post">
            <h4>Account erstellen</h4>
            <hr />
            <div asp-validation-summary="All" class="text-danger"></div>
            <div class="form-group">
                <label asp-for="Input."></label>
                <input asp-for="Input." class="form-control" />
                <span asp-validation-for="Input.Email" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Input.Email"></label>
                <input asp-for="Input.Email" class="form-control" />
                <span asp-validation-for="Input.Email" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Input.Email"></label>
                <input asp-for="Input.Email" class="form-control" />
                <span asp-validation-for="Input.Email" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Input.Email"></label>
                <input asp-for="Input.Email" class="form-control" />
                <span asp-validation-for="Input.Email" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Input.Password"></label>
                <input asp-for="Input.Password" class="form-control" />
                <span asp-validation-for="Input.Password" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Input.ConfirmPassword"></label>
                <input asp-for="Input.ConfirmPassword" class="form-control" />
                <span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
            </div>
            <button type="submit" class="btn btn-primary">Register</button>
        </form>

In the prebuild app all asp- tags are bold in dark purple. In mine they look like default html tags. Moreover there is no Intellisense available.

Does anybody know what I did wrong here?

Also could someone explain me when I should create a rezor component instead of a razor page?

Thanks in advance! Best Marvin


Solution

  • I found a solution for the problem. I need to add

    @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
    

    To my Razorpage file.