當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。