Asp.net-Mvc
web.config 中的 <customErrors> 在哪裡用於 MVC 應用程序?
我正在嘗試在我的 MVC 4 應用程序中實現自定義錯誤處理。我不確定我的 web.config
<customErrors>應該放在哪裡,以及我需要包含在其中的一般資訊。
<customErrors>進去<system.web>:<configuration> <system.web> <customErrors mode="RemoteOnly"> <error statusCode="500" redirect="~/Error/InternalServer" /> <error statusCode="404" redirect="~/Error/NotFound" /> </customErrors> </system.web> </configuration>
redirect根據您的路線修改屬性值。您還可以通過向元素添加defaultRedirect屬性來實現包羅萬象的重定向。customErrors有關詳細資訊,請參閱此 MSDN 文章。