我有一个VS .net项目,它使用带有剃刀视图的.net mvc 5,因此大多数视图都使用.cshtml @..
语法
如何自定义404.aspx页面以用于较旧的&lt;%=%&gt;语法内联?例如,当我尝试使用<%=Url.Action..
时,在我的404.aspx页面中,我收到一条错误消息the name Url doesn't exist in the current context
。我已经在web.config中设置了customErrors,它工作正常,但无法在404.aspx中获取内联逻辑。
我应该如何设置404.aspx
页?
<%@ Page Language="C#" %>
<% Response.StatusCode = 404; %>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Not Found</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- Error Page for ASP.NET 404 Not Found Errors -->
<div class="navbar navbar-inverse navbar-static-top" id="top-navbar">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<%=Url.Action("Index", "Default", new { area = "" })%>">
Link
</a>
</div>
</div>
</div>
<div class="container">
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
</div>
</body>
</html>