0

Response.Write("String Goes here.");

Above statement showing an error inside my .net core 2.1 project's controller .Even if i have included the references like System.web .

Exact Error msg:

Error CS1061 'HttpResponse' does not contain a definition for 'Write' and no accessible extension method 'Write' accepting a first argument of type 'HttpResponse' could be found (are you missing a using directive or an assembly reference?)

Thank you

  • Without the error it's hard to help. I'm assuming this is an MVC application where Response.Write does not exist, [see this answer](https://stackoverflow.com/questions/33847767/what-is-response-write-in-asp-net-mvc) – Iztoksson Jun 19 '20 at 09:43
  • Im using .net mvc core 2.1 – Code dreamer Jun 19 '20 at 10:43
  • I'm getting error msg : Error CS1061 'HttpResponse' does not contain a definition for 'Write' and no accessible extension method 'Write' accepting a first argument of type 'HttpResponse' could be found (are you missing a using directive or an assembly reference?) – Code dreamer Jun 19 '20 at 10:44
  • As I said, MVC doesn't have Response.Write (like the old Asp.net Forms did), you need to use another approach, see the link in my first comment. – Iztoksson Jun 19 '20 at 10:54

1 Answers1

2

Use Microsoft.AspNetCore.Http Nuget Package and namespace Microsoft.AspNetCore.Http then you can use :

using Microsoft.AspNetCore.Http ;
....
Response.Write("String Goes here.");