.net核心在部署剃刀页面时未在浏览器页面中显示消息.net核心应用

时间:2020-02-21 14:12:42

标签: .net razor core

拥有一个可运行的.net核心程序,并已将i.p.将其列入白名单,并且虽然在无效的IP地址不会显示CRUD页面的情况下,其行为仍然如此。

但是,希望它显示一条消息,建议用户在尝试访问时与其联系。

下面的代码片段。

基于https://docs.microsoft.com/en-us/aspnet/core/security/ip-safelist?view=aspnetcore-2.1

在调试模式下以Visual Studio代码在自己的PC上运行时有效,但是在部署到Web服务器时仅显示空白页面

关于如何使它在浏览器页面本身中显示消息的任何想法。

if (badIp) 
        {
             _logger.LogInformation(
             " Please contact IT  to add your ip address to list of valid ip addresses. Forbidden Request from Remote IP address: {RemoteIp}", remoteIp);
            context.Result = new StatusCodeResult(200);
            string valueString = "Only whitelisted I.P. Addresses may access this application." +
                                    "\r\n" +
                                     "\r\n" +
                                "Please contact IT team to determine if your IP address can be added for access";
            context.HttpContext.Response.WriteAsync(valueString);
            return;

        }

0 个答案:

没有答案