我有一个ASP.NET托管的WCF应用程序。目前,它显示403.14 - Forbidden: The Web server is configured to not list the contents of this directory.
错误。
我想用更友好的东西取而代之。但是,我想向localhost
显示与其他访问者不同的页面。 localhost
页面应该有更多关于在文档中查看位置的信息。
答案 0 :(得分:1)
您可以向WCF项目添加Default.aspx
。在后面的代码中,您可以在Page_Load
if (HttpContext.Current.Request.IsLocal)
{
// Show localhost information
// or use Server.Transfer to move to another aspx file.
}
答案 1 :(得分:0)
你可以这样做
bool isLocal = HttpContext.Current.Request.IsLocal;
然后根据isLocal显示您想要的任何内容或重定向。
答案 2 :(得分:0)
尝试在webconfig中使用redirectmode RemoteOnly。然后您的远程连接将显示您的自定义错误,但在本地您将收到死亡的黄色屏幕。
<system.web>
<customErrors defaultRedirect="SiteErrorPage.aspx" mode="RemoteOnly">
</customErrors>
<system.web>