Mike Phares 83789cdd91 Added ControllerExtensions to be used instead of HtmlViewRenderer for net8
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-19 13:29:54 -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
}