How to set page title in ASP.NET MVC view?

In the ASP.NET MVC view, I have the following code:

<% Page.Title = ViewData.Model.MyPageTitle; %>

and when I go to it, I see that the Page.Title value changes the title that I want, but when you look at the page title specified in the browser, it has not been changed. It looks like this value is being overwritten later.

Any ideas on how the page title should be set if you want to do it dynamically?

+3
source share
2 answers

I would recommend 2 options.

First you had to do something on your main page to do something like this.

<% Page.Title = ViewData["Title"] ?? "Default title"; %>

/, , HTML.

0

- , ...

-1

Source: https://habr.com/ru/post/1707656/


All Articles