浏览页面时,我收到错误:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /WebResource.axd
Version Information: Microsoft .NET Framework Version:4.0; ASP.NET Version:4.0.33
错误正如预期的那样,我需要的是一种隐藏/删除版本信息的方法。!?如果有的话...
最佳答案
创建一个您希望用户看到的自定义页面,然后在 web.config
文件中添加类似内容
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="404.aspx" redirectMode="ResponseRedirect">
<error statusCode="404" redirect="404.aspx" />
...
</customErrors>
</system.web>
有3种不同的模式On
、Off
、RemoteOnly
开 - 指定启用自定义错误。如果未指定 defaultRedirect 属性,用户会看到一般错误。自定义错误会显示给远程客户端和本地主机。
关闭 - 指定禁用自定义错误。详细的 ASP.NET 错误会显示给远程客户端和本地主机。
RemoteOnly - 指定仅向远程客户端显示自定义错误,而向本地主机显示 ASP.NET 错误。这是默认值。
默认为RemoteOnly
进一步阅读here 。您也可能想看看这个 answer 如果您想了解 customErrors
和 httpErrors
关于asp.net - 如何从服务器错误 "the resource cannot be found"中删除版本信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29944480/