How to fix Can't use Server.MapPath in ASP.NET MVC

Server.MapPath returns the physical file path corresponding to the specified virtual path

If you encounter a Server.MapPath or the visual intellisense doesen't have quick result options, you can fix as shown below

string path = System.Web.HttpContext.Current.Server.MapPath($"~/bin/reports");


string path = System.Web.Hosting.HostingEnvironment.MapPath($"~/bin/reports");

And don't forget to add a reference to System.Web.dll