当前位置: 首页>>代码示例>>C#>>正文


C# HttpResponse.Send方法代码示例

本文整理汇总了C#中System.Web.HttpResponse.Send方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.Send方法的具体用法?C# HttpResponse.Send怎么用?C# HttpResponse.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.Send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BlockingHandler

        public void BlockingHandler(IHttpClientContext context0, IHttpRequest request, IHttpResponse response)
        {
            //  UUID capsID;
            bool success;

            string path = request.Uri.PathAndQuery;//.TrimEnd('/');
            if (path.Contains("5580"))
            {
                path = path.Replace("?:5580/", "");
            }
            string pathd = HttpUtility.UrlDecode(path);//.TrimEnd('/');
            LogInfo("_listener " + path + " from " + request.RemoteEndPoint);
            if (request.UriPath.EndsWith(".ico"))
            {
                response.Status = HttpStatusCode.NotFound;
                response.Send();
            }
            var wrresp = new WriteLineToResponse(this, response);

            string botname = GetVariable(request, "bot", GetVariable(request, "botid", null));

            ScriptExecutor _botClient = clientManager.GetScriptExecuter(botname);
            if (_botClient == null)
            {
                response.Status = HttpStatusCode.ServiceUnavailable;
                response.Send();
                return;
            }

            // Micro-posterboard
            if (pathd.StartsWith("/posterboard"))
            {
                string slot = path;
                string value = "";
                value = _botClient.getPosterBoard(slot) as string;
                if (value != null)
                    if (value.Length > 0) { LogInfo(String.Format(" board response: {0} = {1}", slot, value)); }
                AddToBody(response, "<xml>");
                AddToBody(response, "<slot>");
                AddToBody(response, "<path>" + path + "</path>");
                AddToBody(response, "<value>" + (value ?? "") + "</value>");
                AddToBody(response, "</slot>");
                AddToBody(response, "</xml>");

                wrresp.response = null;
                response.Status = HttpStatusCode.OK;
                response.Send();
                return;
            }

            bool useHtml = false;
            if (request.Method == "POST")
            {
                var fdp = new FormDecoderProvider();
                fdp.Add(new MultipartDecoder());
                fdp.Add(new UrlDecoder());
                request.DecodeBody(fdp);
            }

            if (path.StartsWith("/?") || path.StartsWith("/test"))
            {
                useHtml = true;
            }
            if (DLRConsole.IsDougsMachine)
            {
                useHtml = true;
            }
            try
            {
                if (OverrideHandlers(request, response)) return;

                if (useHtml)
                {
                    AddToBody(response, "<html>");
                    AddToBody(response, "<head>");
                    botname = GetVariable(request, "bot", _botClient.GetName());

                    AddToBody(response, "<title>" + botname + "</title>");
                    AddToBody(response, "</head>");
                    AddToBody(response, "<body>");
                    AddToBody(response, "<pre>");
                    foreach (var p in request.Param.AsEnumerable())
                    {
                        foreach (var item in p.Values)
                        {
                            AddToBody(response, "" + p.Name + " = " + item);
                        }
                    }
                    AddToBody(response, "</pre>");
                    AddToBody(response, "<a href='" + request.Uri.PathAndQuery + "'>"
                                        + request.Uri.PathAndQuery + "</a>");
                    AddToBody(response, "<pre>");
                }


                string cmd = GetVariable(request, "cmd", "MeNe");

                CmdResult res;
                // this is our default handler
                if (cmd != "MeNe")
//.........这里部分代码省略.........
开发者ID:drzo,项目名称:opensim4opencog,代码行数:101,代码来源:ClientManagerHttpServer.cs


注:本文中的System.Web.HttpResponse.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。