Mike Phares b586da5c82 Removed PdfViewController, HtmlViewRenderer and FakeView to be replaced with ViewEngineResult Render method
Added HttpException class for missing HttpException for net8

Wrapped HttpContext.Session, GetJsonResult, IsAjaxRequest and GetUserIdentityName in controllers for net8

Added AuthenticationService to test Fab2ApprovalMKLink code for net8

Compile conditionally flags to debug in dotnet core
2025-05-23 12:27:09 -07:00

47 lines
1.1 KiB
C#

#if !NET8
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
#endif
#if !NET8
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
using System.IO;
#endif
namespace Fab2ApprovalSystem.PdfGenerator;
public class BinaryContentResult : ActionResult {
private readonly string contentType;
private readonly byte[] contentBytes;
public BinaryContentResult(byte[] contentBytes, string contentType) {
this.contentBytes = contentBytes;
this.contentType = contentType;
}
#if !NET8
public override void ExecuteResult(ControllerContext context) {
var response = context.HttpContext.Response;
response.Clear();
response.Cache.SetCacheability(HttpCacheability.Public);
response.ContentType = contentType;
using (var stream = new MemoryStream(contentBytes)) {
stream.WriteTo(response.OutputStream);
stream.Flush();
}
}
#endif
}