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); } }
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; } }
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); } }
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(); } }
/// <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; }
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); } } } }
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(); } }
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)); }
/// <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)); }
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); }
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); }
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); }
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(""", "\\""))); } else { if (!String.IsNullOrEmpty(contentType)) { httpResponse.ContentType = contentType; } else { httpResponse.ContentType = "application/json"; } if (contentEncoding != null) { httpResponse.ContentEncoding = contentEncoding; } httpResponse.Write(jsonResponse); } }
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"); } }
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); }
public void SendMessages(HttpResponseBase response, HttpRequestBase request, IEnumerable<Message> messages) { if ( !String.IsNullOrEmpty( CometHttpHandler.AllowOrigin ) && request.Headers["Origin"]!=null ) { if ( CometHttpHandler.IsOriginAllowed( new Uri( request.Headers["Origin"] ) ) ) { response.AddHeader( "Access-Control-Allow-Origin", request.Headers["Origin"] ); response.AddHeader( "Access-Control-Allow-Methods", "POST, GET, OPTIONS" ); response.AddHeader( "Access-Control-Max-Age", ( 24 * 60 * 60 ).ToString() ); if ( request.Headers["Access-Control-Request-Headers"] != null ) { response.AddHeader( "Access-Control-Allow-Headers", request.Headers["Access-Control-Request-Headers"] ); } } } response.ContentType = "text/json"; response.Write(MessageConverter.ToJson(messages)); }
/// <summary> /// 在接收异步上传数据的 Action 中调用此方法以完成数据的上传 /// </summary> /// <param name="request"></param> /// <param name="response"></param> /// <param name="targetDirectory">上传到的服务器目录,默认“~/Temps/”</param> /// <param name="maxFileSize">最大上传文件大小,默认 4194304 bytes</param> /// <param name="allowedFileTypes">允许的文件扩展名,默认“*.jpeg;*.jpg;*.png;*.gif;*.bmp”</param> public static void Upload(HttpRequestBase request, HttpResponseBase response, string targetDirectory = "~/Temps/", int maxFileSize = 4194304, string allowedFileTypes = "*.jpeg;*.jpg;*.png;*.gif;*.bmp") { response.Charset = "UTF-8"; HttpPostedFileBase file = request.Files[0]; if (file.ContentLength > maxFileSize) return; string fileExtension = Path.GetExtension(file.FileName).ToLower(); if (allowedFileTypes.ToLower().IndexOf(fileExtension) < 0 && allowedFileTypes.IndexOf("*.*") < 0) return; string directory = HttpContext.Current.Server.MapPath(targetDirectory), filename = Guid.NewGuid().ToString("N") + fileExtension; if (!Directory.Exists(directory)) Directory.CreateDirectory(directory); file.SaveAs(Path.Combine(directory, filename)); response.Write(filename); }
protected virtual void SerializeData(HttpResponseBase response) { if (ErrorMessages.Any()) { Data = new { ErrorMessage = string.Join("\n", ErrorMessages), ErrorMessages = ErrorMessages.ToArray() }; response.StatusCode = 400; } if (Data == null) return; response.Write(Data.ToJson()); }
protected override void WriteFile(HttpResponseBase response) { var builder = new StringBuilder(); var stringWriter = new StringWriter(builder); stringWriter.Write(AddColumnTitles(_data)); foreach (var item in _data) { var properties = item.GetType().GetProperties(); foreach (var prop in properties) { stringWriter.Write(GetValue(item, prop.Name)); stringWriter.Write(", "); } // This removes the trailing comma and white space. stringWriter.GetStringBuilder().Length -= 2; stringWriter.WriteLine(); } response.Write(builder); }
protected override void WriteFile(System.Web.HttpResponseBase response) { iCalendar iCal = new iCalendar(); var evnt = iCal.Create <Event>(); evnt.Summary = _info.Name; evnt.Start = new iCalDateTime(_info.StartDate); evnt.Duration = _info.Duration; evnt.GeographicLocation = _info.Geo; evnt.Location = _info.Location; evnt.Url = new Uri(_info.Url); //iCal.Events.Add(evnt); var ser = new iCalendarSerializer(); string result = ser.SerializeToString(iCal); //iCalendarSerializer serializer = new iCalendarSerializer(iCal); //string result = serializer.SerializeToString(); response.ContentEncoding = Encoding.UTF8; response.Write(result); }
private void SerializeData(HttpResponseBase response) { if (ErrorMessages.Any()) { Data = new { ErrorMessage = string.Join("\n", ErrorMessages), ErrorMessages = ErrorMessages.ToArray() }; // Bad Request // The request could not be understood by the server due to malformed syntax. // The client SHOULD NOT repeat the request without modifications. response.StatusCode = 400; } if (Data == null) return; response.Write(Data.ToJson(IncludeNull, MaxDepth)); }
private static void Json(HttpResponseBase response, object data) { JavaScriptSerializer serializer = new JavaScriptSerializer(); response.Write(serializer.Serialize(data)); }
private static void ProcessRequestInternal( HttpResponseBase response, string decryptedString, VirtualFileReader fileReader) { if (String.IsNullOrEmpty(decryptedString)) { Throw404(); } bool zip; bool singleAssemblyReference; // See GetScriptResourceUrl comment below for first character meanings. switch (decryptedString[0]) { case 'Z': case 'z': singleAssemblyReference = true; zip = true; break; case 'U': case 'u': singleAssemblyReference = true; zip = false; break; case 'Q': case 'q': singleAssemblyReference = false; zip = true; break; case 'R': case 'r': singleAssemblyReference = false; zip = false; break; case 'T': OutputEmptyPage(response, decryptedString.Substring(1)); return; default: Throw404(); return; } decryptedString = decryptedString.Substring(1); if (String.IsNullOrEmpty(decryptedString)) { Throw404(); } string[] decryptedData = decryptedString.Split('|'); if (singleAssemblyReference) { // expected: <assembly>|<resource>|<culture>[|#|<hash>] if (decryptedData.Length != 3 && decryptedData.Length != 5) { // The decrypted data must have 3 parts plus an optional 2 part hash code separated by pipes. Throw404(); } } else { // expected: <assembly1>|<resource1a>,<culture1a>,<resource1b>,<culture1b>,...|<assembly2>|<resource2a>,<culture2a>,<resource2b>,<culture2b>,...|#|<hash> if (decryptedData.Length % 2 != 0) { // The decrypted data must have an even number of parts separated by pipes. Throw404(); } } StringBuilder script = new StringBuilder(); string firstContentType = null; if (singleAssemblyReference) { // single assembly reference, format is // <assembly>|<resource>|<culture> string assemblyName = decryptedData[0]; string resourceName = decryptedData[1]; string cultureName = decryptedData[2]; Assembly assembly = GetAssembly(assemblyName); if (assembly == null) { Throw404(); } script.Append(ScriptResourceAttribute.GetScriptFromWebResourceInternal( assembly, resourceName, String.IsNullOrEmpty(cultureName) ? CultureInfo.InvariantCulture : new CultureInfo(cultureName), zip, out firstContentType )); } else { // composite script reference, format is: // <assembly1>|<resource1a>,<culture1a>,<resource1b>,<culture1b>,...|<assembly2>|<resource2a>,<culture2a>,<resource2b>,<culture2b>,... // Assembly is empty for path based scripts, and their resource/culture list is <path1>,<path2>,... // If an assembly starts with "#", the segment is ignored (expected that this includes a hash to ensure // url uniqueness when resources are changed). Also, for forward compatibility '#' segments may contain // other data. bool needsNewline = false; for (int i = 0; i < decryptedData.Length; i += 2) { string assemblyName = decryptedData[i]; bool hasAssembly = !String.IsNullOrEmpty(assemblyName); if (hasAssembly && assemblyName[0] == '#') { // hash segments are ignored, it contains a hash code for url uniqueness continue; } Debug.Assert(!String.IsNullOrEmpty(decryptedData[i + 1])); string[] resourcesAndCultures = decryptedData[i + 1].Split(','); if (resourcesAndCultures.Length == 0) { Throw404(); } Assembly assembly = hasAssembly ? GetAssembly(assemblyName) : null; if (assembly == null) { // The scripts are path-based if (firstContentType == null) { firstContentType = "text/javascript"; } for (int j = 0; j < resourcesAndCultures.Length; j++) { Encoding encoding; // DevDiv Bugs 197242 // path will either be absolute, as in "/app/foo/bar.js" or app relative, as in "~/foo/bar.js" // ToAbsolute() ensures it is in the form /app/foo/bar.js // This conversion was not done when the url was created to conserve url length. string path = _bypassVirtualPathResolution ? resourcesAndCultures[j] : VirtualPathUtility.ToAbsolute(resourcesAndCultures[j]); string fileContents = fileReader(path, out encoding); if (needsNewline) { // Output an additional newline between resources but not for the last one script.Append('\n'); } needsNewline = true; script.Append(fileContents); } } else { Debug.Assert(resourcesAndCultures.Length % 2 == 0, "The list of resource names and cultures must have an even number of parts separated by commas."); for (int j = 0; j < resourcesAndCultures.Length; j += 2) { try { string contentType; string resourceName = resourcesAndCultures[j]; string cultureName = resourcesAndCultures[j + 1]; if (needsNewline) { // Output an additional newline between resources but not for the last one script.Append('\n'); } needsNewline = true; script.Append(ScriptResourceAttribute.GetScriptFromWebResourceInternal( assembly, resourceName, String.IsNullOrEmpty(cultureName) ? CultureInfo.InvariantCulture : new CultureInfo(cultureName), zip, out contentType )); if (firstContentType == null) { firstContentType = contentType; } } catch (MissingManifestResourceException ex) { throw Create404(ex); } catch (HttpException ex) { throw Create404(ex); } } } } } if (ScriptingScriptResourceHandlerSection.ApplicationSettings.EnableCaching) { PrepareResponseCache(response); } else { PrepareResponseNoCache(response); } response.ContentType = firstContentType; if (zip) { using (MemoryStream zipped = new MemoryStream()) { using (Stream outputStream = new GZipStream(zipped, CompressionMode.Compress)) { // The choice of an encoding matters little here. // Input streams being of potentially different encodings, UTF-8 is the better // choice as it's the natural encoding for JavaScript. using (StreamWriter writer = new StreamWriter(outputStream, Encoding.UTF8)) { writer.Write(script.ToString()); } } byte[] zippedBytes = zipped.ToArray(); response.AddHeader("Content-encoding", "gzip"); response.OutputStream.Write(zippedBytes, 0, zippedBytes.Length); } } else { // Bug DevDiv #175061, we don't want to force any encoding here and let the default // encoding apply no matter what the incoming scripts might have been encoded with. response.Write(script.ToString()); } }
private static void OutputEmptyPage(HttpResponseBase response, string title) { PrepareResponseCache(response); response.Write(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""> <html xmlns=""http://www.w3.org/1999/xhtml""><head><script type=""text/javascript"">parent.Sys.Application._onIFrameLoad();</script><title>" + HttpUtility.HtmlEncode(title) + @"</title></head><body></body></html>"); }
/// <summary> /// Packages the response. <c>Flush()</c> would be called in this method. /// </summary> /// <param name="response">The response.</param> /// <param name="data">The data.</param> /// <param name="ex">The ex.</param> /// <param name="acceptEncoding">The accept encoding.</param> /// <param name="noBody">if set to <c>true</c> [no body].</param> /// <param name="settings">The settings.</param> public static void PackageResponse(HttpResponseBase response, object data, BaseException ex = null, string acceptEncoding = null, bool noBody = false, RestApiSettings settings = null) { if (response != null) { if (settings == null) { settings = defaultRestApiSettings; } var objectToReturn = ex != null ? (settings.EnableOutputFullExceptionInfo ? ex.ToExceptionInfo() : new SimpleExceptionInfo { Message = ex.Hint != null ? (ex.Hint.Message ?? ex.Hint.Cause) : ex.RootCause.Message, Data = data == null ? null : JObject.FromObject(data), Code = ex.Hint?.Code ?? ex.Code } as object) : data; response.Headers.Add(HttpConstants.HttpHeader.SERVERNAME, EnvironmentCore.ServerName); response.Headers.AddIfNotNull(HttpConstants.HttpHeader.TRACEID, ApiTraceContext.TraceId); response.StatusCode = (int)(ex == null ? (noBody ? HttpStatusCode.NoContent : HttpStatusCode.OK) : ex.Code.ToHttpStatusCode()); if (!noBody) { response.ContentType = "application/json"; if (settings.EnableContentCompression) { acceptEncoding = acceptEncoding.SafeToString().ToLower(); if (acceptEncoding.Contains("gzip")) { response.Filter = new System.IO.Compression.GZipStream(response.Filter, System.IO.Compression.CompressionMode.Compress); response.Headers.Remove(HttpConstants.HttpHeader.ContentEncoding); response.AppendHeader(HttpConstants.HttpHeader.ContentEncoding, "gzip"); } else if (acceptEncoding.Contains("deflate")) { response.Filter = new System.IO.Compression.DeflateStream(response.Filter, System.IO.Compression.CompressionMode.Compress); response.Headers.Remove(HttpConstants.HttpHeader.ContentEncoding); response.AppendHeader(HttpConstants.HttpHeader.ContentEncoding, "deflate"); } } response.Write(objectToReturn.ToJson(true, JsonConverters)); } response.Headers.Add(HttpConstants.HttpHeader.SERVEREXITTIME, DateTime.UtcNow.ToFullDateTimeTzString()); response.Flush(); } }
public static void Export(HttpResponseBase Response, string strStudentId) { HallTicketDataAccess dataaccess = new HallTicketDataAccess(); DataTable dt = dataaccess.GetHallTickets(strStudentId); Response.AddHeader("Content-Disposition", "attachment; filename=" + "PrintHalltickets.doc"); Response.Write("<html " + "xmlns:o='urn:schemas-microsoft-com:office:office' " + "xmlns:w='urn:schemas-microsoft-com:office:word'" + "xmlns='http://www.w3.org/TR/REC-html40'>" + "<head><title>Time</title>"); Response.Write("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">"); Response.Write("<meta name=ProgId content=Word.Document>"); Response.Write("<meta name=Generator content=\"Microsoft Word 9\">"); Response.Write("<meta name=Originator content=\"Microsoft Word 9\">"); Response.Write("<!--[if gte mso 9]>" + "<xml>" + "<w:WordDocument>" + "<w:View>Print</w:View>" + "<w:Zoom>90</w:Zoom>" + "<w:DoNotOptimizeForBrowser/>" + "</w:WordDocument>" + "</xml>" + "<![endif]-->"); Response.Write("<style> @page" + "{size:8.5in 11.0in; mso-first-footer:ff1; mso-footer: f1;" + " margin:0.2in 0.2in 0.2in 0.2in ; " + " mso-header-margin:.1in; " + " mso-footer-margin:.1in; mso-paper-source:0;}" + " div.Section1" + " {page:Section1;}" + "p.MsoFooter, li.MsoFooter, div.MsoFooter{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Verdana';}" + "p.MsoHeader, li.MsoHeader, div.MsoHeader {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Verdana';}" + "table#hrdftrtbl { margin:0in 0in 0in 0.1in; }" + "-->" + "</style>" + "</head>"); Response.Write("<body lang=EN-US style='tab-interval:.5in'>"); Response.Write("<table stle=\"width: 8.5in;\">"); foreach (DataRow dr in dt.Rows) { Response.Write("<tr>"); Response.Write("<td colspan=2 style=\"height: 0.25in;\">"); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td colspan=2 align=\"center\">Exam Name</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td colspan=2 style=\"height: 0.25in;\">"); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("Hall Ticket Number")); Response.Write("</td>"); Response.Write("<td>" + dr["HallTicketNo"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("Student Name")); Response.Write("</td>"); Response.Write("<td>" + dr["Name"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("Father's Name")); Response.Write("</td>"); Response.Write("<td>" + dr["FatherName"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("School Name")); Response.Write("</td>"); Response.Write("<td>" + dr["SchoolName"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("Course Code")); Response.Write("</td>"); Response.Write("<td>" + dr["CourseCode"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("Exam Schedule")); Response.Write("</td>"); Response.Write("<td>" + dr["ExamSchedule"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); Response.Write("<tr>"); Response.Write("<td>" + GetSideHeader("Exam Center Address")); Response.Write("</td>"); Response.Write("<td>" + dr["ExamCenterAddress"].ToString()); Response.Write("</td>"); Response.Write("</tr>"); } Response.Write("</table>"); Response.Write("</body></head>"); Response.Write("</html>"); Response.Flush(); }
protected void WriteInvocations(HttpResponseBase response, IEnumerable<SheepJaxInvoke> invocations, JsonSerializerSettings settings) { response.Write(JsonConvert.SerializeObject(invocations, Formatting.None, settings)); }
/// <summary> /// 输出JS文本到客户端 public static void WriteJavaScript(this HttpResponseBase Response, JavaScript script) { Response.ContentType = "text/html"; Response.ContentEncoding = Encoding.UTF8; Response.Write(script.ToString()); }
protected virtual void WriteMessage(HttpResponseBase response) { response.Write(response.Status); string message = this.Message; if (!String.IsNullOrEmpty(message)) { response.Write(": "); response.Write(message); } }
public void WriteToResponse(HttpResponseBase response) { if (string.IsNullOrEmpty(ContentType)) { response.ContentType = "application/json"; } else { response.ContentType = ContentType; } response.ContentEncoding = Encoding.UTF8; response.Write(Serializer.ToJson(ToCustomResult())); }
public static void ExportHtml(ExportEventArgs options, HttpResponseBase response) { response.Write(options.Document); }
private void Err(string message, HttpResponseBase response) { StandardHeaders(response); response.AddHeader("x-ping-error", message); response.StatusCode = _opts.ErrorCode; response.Write(_opts.ErrorText); }