i want get current page title in controller ? how to access and do it ?
The controller sets the title the controller does not read the title. The standard layout template has a ViewData["Title"] that renders the title set in the controller.
i want get current page title in controller ? how to access and do it ?
Just make a default ASP.NET Core web application and select MVC when creating a new app in Visual Studio. Then check the codes given on the Views. You can find how ViewBag is used to work with page titles.
Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Member
39 Points
199 Posts
get current page title in .net core
May 31, 2020 10:10 AM|elahi1mahdi|LINK
hi
i want get current page title in controller ? how to access and do it ?
All-Star
53011 Points
23596 Posts
Re: get current page title in .net core
May 31, 2020 12:02 PM|mgebhard|LINK
The controller sets the title the controller does not read the title. The standard layout template has a ViewData["Title"] that renders the title set in the controller.
Reference documentation.
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/layout?view=aspnetcore-3.1
Participant
1253 Points
935 Posts
Re: get current page title in .net core
May 31, 2020 02:27 PM|yogyogi|LINK
Just make a default ASP.NET Core web application and select MVC when creating a new app in Visual Studio. Then check the codes given on the Views. You can find how ViewBag is used to work with page titles.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Member
39 Points
199 Posts
Re: get current page title in .net core
Jun 02, 2020 04:39 AM|elahi1mahdi|LINK
no, i have logUser_tb to create log for any user that go to pages
in logUser_tb i save this property
User_Id , Page_Url , Date , Page_Title
i create a action filter that save log for user
in action filter how can i get page title ?
All-Star
53011 Points
23596 Posts
Re: get current page title in .net core
Jun 02, 2020 10:03 AM|mgebhard|LINK
Not possible as explained clearly above. You need to come up with a design to store the page title in a database table.