Asp.net mvc 3 在MVC3中创建默认站点页面标题

Asp.net mvc 3 在MVC3中创建默认站点页面标题,asp.net-mvc-3,razor,default,page-title,Asp.net Mvc 3,Razor,Default,Page Title,我的布局文件中包含以下内容: @{ ViewBag.Title = "Default page title"; } <!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> </head> ..... 但是,页面标题显示为“默认页面标题” 如何将页面标题显示为“主页”?如果我没有为视图中的ViewBag.title指定值,我只希望显示“默认页面

我的布局文件中包含以下内容:

@{
    ViewBag.Title = "Default page title";
}

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
</head>
.....
但是,页面标题显示为“默认页面标题”

如何将页面标题显示为“主页”?如果我没有为视图中的
ViewBag.title
指定值,我只希望显示“默认页面标题”。

更改行:

ViewBag.Title = "Default page title"; 

试试这个

<title>@(String.IsNullOrEmpty(ViewBag.Title) ? "Default page title" : ViewBag.Title)</title>
@(String.IsNullOrEmpty(ViewBag.Title)?“默认页面标题”:ViewBag.Title)

干杯,我是MVC新手,我认为它的工作原理很像
页面。Title
适用于web表单。感谢againI,因为
ViewBag
仍然是页面标题的中心信息。
ViewBag.Title = ViewBag.Title ?? "Default page title"; 
<title>@(String.IsNullOrEmpty(ViewBag.Title) ? "Default page title" : ViewBag.Title)</title>