4

I've done most of the part but here are some things that I really dont know much about..

Also how to end request/completerequest? Generate the code into .net core code

private static void SetCorsResponse(HttpContext context)
    {

        context.Response.Headers.Append("Access-Control-Allow-Methods", "OPTIONS,GET,POST,PUT,PATCH,DELETE");
        context.Response.Headers.Append("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With");
        context.Response.Headers.Append("Access-Control-Expose-Headers", "*");
        context.Response.StatusCode = 200;
        **HttpContext.Current.ApplicationInstance.CompleteRequest();**
    }
KakaMir
  • 59
  • 1
  • 5
  • Can you post some more examples of your code, in particular you Controller method. The header you're tring to set is a CORS header, which is now a middleware here: https://learn.microsoft.com/en-us/aspnet/core/security/cors Also, I don't understand what you're doing with the `CompleteRequest` call. – Dr Rob Lang Mar 03 '17 at 09:53

1 Answers1

-1

ASP.NET Core has removed the HttpContext.Current, so getting it will not be possible.You can acces the current HTTP Context from a controller using HttpContext .See more information here How to get HttpContext.Current in ASP.NET Core?

Community
  • 1
  • 1
Vlad
  • 14
  • 3
  • I've done exacly like that post said, but somehow I have to Set the value of the Headers.. I know httpcontext.current isnt possible anymore, thats why I created a middleware class – KakaMir Mar 03 '17 at 09:51
  • Middleware no have controllers – nim Dec 31 '20 at 19:46