How to fix Can't use Server.MapPath in ASP.NET MVC
By FoxLearn 2/18/2024 1:35:03 AM 55
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");
or
string path = System.Web.Hosting.HostingEnvironment.MapPath($"~/bin/reports");
And don't forget to add a reference to System.Web.dll
- How to fix "InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager'"
- How to fix 'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson'
- ASP.NET Core: How to Create RDLC Report in ASP.NET Core
- ASP.NET MVC: Free Responsive Templates
- How to fix Assets file 'project.assets.json' not found
- How to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'
- How to set cookie ValidationInterval in ASP.NET Core
- How to fix LoginPath not working in ASP.NET Core
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024