我正在尝试获取一个消息页面,以便在访问者浏览页面时显示自定义消息,例如。 nothere.cshtml或没有现有的文件夹,例如。 / folder / nothere /
我想保持网址可见,而不是重定向
我在system.web
中尝试了以下内容<customErrors defaultRedirect="~/message.cshtml" mode="On" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="~/message.cshtml" />
</customErrors>
以下是system.webserver
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/message.cshtml" responseMode="ExecuteURL" />
</httpErrors>
但是,当浏览到不存在的目录时,我在“/”应用程序中收到文件的服务器错误和标准的404错误消息。
我可以使用普通的responseRedirect制作自定义错误消息,但后来网址不保留原始
任何人