asp.net-mvc 如何在 MVC Web 应用程序中设置浏览器标签页标题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25153362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-07 23:11:22  来源:igfitidea点击:

How to set browsers tab page title in MVC web application ?

asp.net-mvc

提问by bnil

I am developing MVC application. When I run the application I can see the title on the tab of browser as

我正在开发 MVC 应用程序。当我运行应用程序时,我可以在浏览器选项卡上看到标题为

Index - My ASP.NET MVC Application.

索引 - 我的 ASP.NET MVC 应用程序。

I want to change it. I have used the <title> my page</title>but its not working.

我想改变它。我用过 <title> my page</title>但它不工作。

How to set it ?

如何设置?

回答by Andy Refuerzo

In your view, make sure you have this:

在您看来,请确保您拥有以下内容:

@{
    ViewBag.Title = "My Page";
}

In Views\Shared\_Layout.cshtml, make sure this is there:

在 中Views\Shared\_Layout.cshtml,确保它在那里:

<title>@ViewBag.Title</title>

回答by jparaya

Change the Views\Shared_Layout.cshtml. Generally it comes with

更改 Views\Shared_Layout.cshtml。通常它带有

<title>@ViewBag.Title - My ASP.Net MVC application</title>