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


C# HttpResponseBase.Write方法代码示例

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


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

示例1: Execute

		public virtual void Execute(HttpResponseBase response)
		{
			if (_isAutomatedTool)
			{
				var console = new UnicornStringConsole();
				ProcessInternal(console);

				response.ContentType = "text/plain";
				response.Write(_title + "\n\n");
				response.Write(console.Output);

				if (console.HasErrors)
				{
					response.StatusCode = 500;
					response.TrySkipIisCustomErrors = true;
				}

				response.End();
			}
			else
			{
				var console = new CustomStyledHtml5WebConsole(response);
				console.Title = _title;
				console.Render(ProcessInternal);
			}
		}
开发者ID:hbopuri,项目名称:Unicorn,代码行数:26,代码来源:WebConsoleResponse.cs

示例2: SaveSectionToDb

		private static void SaveSectionToDb(List<string> section, int section_id, HttpResponseBase response)
		{
			string url = String.Empty;
			int ch_count = 1;
			int current_ch = 1;
			XDocument xml = null;
			int chapter_id = 0;
			int book_id = 0;
			foreach (string abbrev in section)
			{
				response.Write("<br /><hr /><br />");
				while(current_ch <= ch_count)
				{
					using(var db = new Entities())
					{
						url = "http://piibel.net/.xml?q=" + abbrev + "%20" + current_ch;
						xml = XDocument.Load(url);
						if(current_ch == 1)
						{
							book_id = AddBook(section_id, xml);
							ch_count = Int32.Parse(xml.Descendants("bible").First().Attribute("pages").Value);
						}
						chapter_id = AddChapter(xml, book_id);
						AddVerses(xml, chapter_id);
						response.Write("Saved: " + abbrev + " " + current_ch + "<br />");
						response.Flush();
						current_ch++;
					}
				}
				current_ch = 1;
				ch_count = 1;
			}
		}
开发者ID:code-keeper,项目名称:bible,代码行数:33,代码来源:HomeController.cs

示例3: ResponseImg

        private void ResponseImg(HttpResponseBase response, string pic)
        {
            try
            {
                string FilePath = AppDomain.CurrentDomain.BaseDirectory;
                FilePath = Path.Combine(FilePath, "App_Data\\" + imgpath);
                string FileFullPath = Path.Combine(FilePath, pic);
                string FileExt = Path.GetExtension(FileFullPath);
                if (U.ExtValid(FileExt))
                {
                    if (File.Exists(FileFullPath))
                    {

                        FileExt = FileExt.ToLower();
                        Image Img = Image.FromFile(FileFullPath);
                        ImageFormat format = ImageFormat.Jpeg;
                        switch (FileExt)
                        {
                            case ".gif":
                                format = ImageFormat.Gif;
                                break;
                            case ".jpg":
                                format = ImageFormat.Jpeg;
                                break;
                            case ".png":
                                format = ImageFormat.Png;
                                break;
                            default:
                                break;

                        }
                        response.ClearContent();
                        response.ContentType = "image/bmp";
                        Img.Save(response.OutputStream, format);
                        Img.Dispose();
                        response.Flush();
                    }
                    else
                    {
                        response.Write("file DO NOT Exists");
                    }
                }
                else
                {
                    response.Write("file DO NOT Allow");
                }
            }
            catch (Exception ex)
            {
                log.Warn(ex.Message);
                log.Warn("imgpath:{0},imgname:{1}", imgpath, imgname);
            }
        }
开发者ID:Xiaoyuyexi,项目名称:LMS,代码行数:53,代码来源:ImgResult.cs

示例4: Apply

        public void Apply(HttpResponseBase response)
        {
            if(response == null)
            {
                throw new ArgumentNullException("response");
            }

            response.Cache.SetCacheability(Cacheability);

            if (HttpStatusCode == HttpStatusCode.SeeOther || Location != null)
            {
                if (Location == null)
                {
                    throw new InvalidOperationException("Missing Location on redirect.");
                }
                if (HttpStatusCode != HttpStatusCode.SeeOther)
                {
                    throw new InvalidOperationException("Invalid HttpStatusCode for redirect, but Location is specified");
                }

                response.Redirect(Location.ToString());
            }
            else
            {
                response.StatusCode = (int)HttpStatusCode;
                response.ContentType = ContentType;
                response.Write(Content);

                response.End();
            }
        }
开发者ID:dmarlow,项目名称:authservices,代码行数:31,代码来源:CommandResult.cs

示例5: GetNotifyData

        /// <summary>
        /// 接收从微信支付后台发送过来的数据并验证签名
        /// </summary>
        /// <returns>微信支付后台返回的数据</returns>
        public WxPayData GetNotifyData(HttpResponseBase response, HttpRequestBase request)
        {
            //接收从微信后台POST过来的数据
            System.IO.Stream s = request.InputStream;
            int count = 0;
            byte[] buffer = new byte[1024];
            StringBuilder builder = new StringBuilder();
            while ((count = s.Read(buffer, 0, 1024)) > 0)
            {
                builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
            }
            s.Flush();
            s.Close();
            s.Dispose();

            //转换数据格式并验证签名
            WxPayData data = new WxPayData();
            try
            {
                data.FromXml(builder.ToString());
            }
            catch(WxPayException ex)
            {
                //若签名错误,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", ex.Message);

                response.Write(res.ToXml());
            }

            return data;
        }
开发者ID:babywzazy,项目名称:Server,代码行数:37,代码来源:Notify.cs

示例6: WriteContent

        private void WriteContent(HttpResponseBase response)
        {
            if (!String.IsNullOrEmpty(ContentType)) {
                response.ContentType = ContentType;
            } else {
                response.ContentType = "application/json";
            }
            if (ContentEncoding != null) {
                response.ContentEncoding = ContentEncoding;
            }

            if (Data != null) {
                if (Data is String) {
                    // write strings directly to avoid double quotes around them caused by JsonSerializer
                    response.Write(Data);
                } else {
                    using (JsonWriter writer = new JsonTextWriter(response.Output)) {
                        JsonSerializer serializer = JsonSerializer.Create(Settings);
                        var converter = ProviderConfiguration.GetDefaultDateTimeConverter();
                        if (converter != null) {
                            serializer.Converters.Add(converter);
                        }
            #if DEBUG
                        writer.Formatting = Formatting.Indented;
            #else
                        writer.Formatting = ProviderConfiguration.GetConfiguration().Debug ? Formatting.Indented : Formatting.None;
            #endif
                        serializer.Serialize(writer, Data);
                    }
                }
            }
        }
开发者ID:sijoyjohn,项目名称:ext-direct-mvc,代码行数:32,代码来源:DirectResult.cs

示例7: SerializeData

        protected virtual void SerializeData(HttpResponseBase response)
        {
            if (ErrorMessages.Any())
            {
                var originalData = Data;
                Data = new
                {
                    Success = false,
                    OriginalData = originalData,
                    ErrorMessage = string.Join("\n", ErrorMessages),
                    ErrorMessages = ErrorMessages.ToArray()
                };

                response.StatusCode = 400;
            }

            var settings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Converters = new JsonConverter[]
                {
                    new StringEnumConverter(),
                },
            };

            response.Write(JsonConvert.SerializeObject(Data, settings));
        }
开发者ID:Rajiv-Kulkarni,项目名称:Failtracker.WindowsAuth,代码行数:27,代码来源:StandardJsonResult.cs

示例8: Apply

        public static void Apply(this CommandResult commandResult, HttpResponseBase response)
        {
            if (commandResult == null)
            {
                throw new ArgumentNullException(nameof(commandResult));
            }

            if (response == null)
            {
                throw new ArgumentNullException(nameof(response));
            }

            if (commandResult.HttpStatusCode == HttpStatusCode.SeeOther || commandResult.Location != null)
            {
                if (commandResult.Location == null)
                {
                    throw new InvalidOperationException("Missing Location on redirect.");
                }
                if (commandResult.HttpStatusCode != HttpStatusCode.SeeOther)
                {
                    throw new InvalidOperationException("Invalid HttpStatusCode for redirect, but Location is specified");
                }

                response.Redirect(commandResult.Location.OriginalString);
            }
            else
            {
                response.StatusCode = (int)commandResult.HttpStatusCode;
                response.ContentType = commandResult.ContentType;
                response.Write(commandResult.Content);

                response.End();
            }
        }
开发者ID:biancini,项目名称:OpenIDConnect-Csharp-Client,代码行数:34,代码来源:CommandResultHttpExtension.cs

示例9: CheckForAuthorizationFailure

 /// <summary>
 /// Checks for authorization failure and if result of ajax call overrides asp.net redirect to return a 401.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="response">The response.</param>
 /// <param name="context">The context.</param>
 internal void CheckForAuthorizationFailure(HttpRequestBase request, HttpResponseBase response, HttpContextBase context)
 {
     if (!request.IsAjaxRequest() || !true.Equals(context.Items["RequestWasNotAuthorized"])) return;
     response.StatusCode = 401;
     response.ClearContent();
     var content = new {title = HttpContext.GetGlobalResourceObject("Session", "Title.SessionHasExpired"), content = HttpContext.GetGlobalResourceObject("Session", "Messsage.SessionHasExpired")};
     var serializer = new JavaScriptSerializer();
     response.Write(serializer.Serialize(content));
 }
开发者ID:ricardo100671,项目名称:Avantech.Common,代码行数:15,代码来源:AjaxAuthorizationModule.cs

示例10: SendMessages

        public void SendMessages(HttpResponseBase response, IEnumerable<Message> messages)
        {
            string messageAsJson = MessageConverter.ToJson(messages);
            string functionName = callback ?? "jsonpcallback";
            string functionCall = string.Format("{0} ( {1} )", functionName, messageAsJson);

            response.ContentType = "text/javascript";
            response.Write(functionCall);
        }
开发者ID:nmosafi,项目名称:aspComet,代码行数:9,代码来源:CallbackPollingTransport.cs

示例11: WriteExcelFile

 public static void WriteExcelFile(HttpResponseBase response,string output,string fileName)
 {
     response.Clear();
     response.Buffer = true;
     response.Charset = "utf-8";
     response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
     response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
     response.ContentType = "application/ms-excel";
     response.Write(output);
 }
开发者ID:jimidzj,项目名称:Inspect,代码行数:10,代码来源:UtilRequest.cs

示例12: ExportCsv

 public static void ExportCsv(ExportEventArgs options, HttpResponseBase response)
 {
     response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}.csv", options.Title));
     response.ContentType = "application/csv";
     if (CultureInfo.CurrentUICulture.Name != "en-US")
     {
         response.ContentEncoding = Encoding.Unicode;
     }
     response.Write(options.Document);
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:10,代码来源:ExportDocumentResult.cs

示例13: Write

        public void Write(HttpResponseBase httpResponse, string contentType, Encoding contentEncoding) {
            string jsonResponse = ToJson();

            if (IsFileUpload) {
                const string s = "<html><body><textarea>{0}</textarea></body></html>";
                httpResponse.ContentType = "text/html";
                httpResponse.Write(String.Format(s, jsonResponse.Replace("&quot;", "\\&quot;")));
            } else {
                if (!String.IsNullOrEmpty(contentType)) {
                    httpResponse.ContentType = contentType;
                } else {
                    httpResponse.ContentType = "application/json";
                }
                if (contentEncoding != null) {
                    httpResponse.ContentEncoding = contentEncoding;
                }

                httpResponse.Write(jsonResponse);
            }
        }
开发者ID:gongyunjing,项目名称:ext-direct-mvc,代码行数:20,代码来源:DirectResponse.cs

示例14: AddSessions

 private void AddSessions(HttpResponseBase response, IEnumerable<Session> sessions)
 {
     foreach (var session in sessions)
     {
         response.Write("BEGIN:VEVENT\n");
         response.Write("DTSTART:" + session.Start.Value.ToiCalTime(+5) + "\n");
         response.Write("SUMMARY:" + session.Title + " with " + session.SpeakerName + "\n");
         response.Write("DESCRIPTION:" + session.Abstract + "\n");
         response.Write("COMMENT: Technology: " + session.Technology + "\n");
         response.Write("COMMENT: Difficulty: " + session.Difficulty + "\n");
         response.Write("LOCATION:" + session.Room + "\n");
         response.Write("END:VEVENT\n");
     }
 }
开发者ID:hgarcia,项目名称:CodeMashSCheduller,代码行数:14,代码来源:CalendarResult.cs

示例15: Render

        public static void Render(ControllerContext context, ViewDataDictionary viewData, TempDataDictionary tempData, HttpResponseBase response, IndexViewModel model)
        {
            RenderHeader(context, viewData, tempData, response, model);
            RenderPreMessages(context, viewData, tempData, response, model);

            foreach (var message in model.Messages.Messages)
            {
                switch (message.Type)
                {
                    case FastLogReader.LineType.Join:
                        response.Write(RenderPartialViewToString(context, viewData, tempData, "~/Views/Unbuffered/MessageTypes/Join.cshtml", message));
                        break;

                    case FastLogReader.LineType.Quit:
                        response.Write(RenderPartialViewToString(context, viewData, tempData, "~/Views/Unbuffered/MessageTypes/Quit.cshtml", message));
                        break;

                    case FastLogReader.LineType.Message:
                        response.Write(RenderPartialViewToString(context, viewData, tempData, "~/Views/Unbuffered/MessageTypes/Message.cshtml", message));
                        break;

                    case FastLogReader.LineType.Meta:
                        response.Write(RenderPartialViewToString(context, viewData, tempData, "~/Views/Unbuffered/MessageTypes/Meta.cshtml", message));
                        break;

                    case FastLogReader.LineType.Action:
                        response.Write(RenderPartialViewToString(context, viewData, tempData, "~/Views/Unbuffered/MessageTypes/Action.cshtml", message));
                        break;

                    default:
                        goto case FastLogReader.LineType.Meta;
                }
            }

            RenderPostMessages(context, viewData, tempData, response, model);
            RenderFooter(context, viewData, tempData, response, model);
        }
开发者ID:MaulingMonkey,项目名称:LoggingMonkey,代码行数:37,代码来源:UnbufferedRenderer.cs


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