Home > DeveloperSection > Forums > Server.MapPath does not exist in currect context
Samuel Fernandes
Samuel Fernandes

Total Post:154

Points:1082
Posted on    October-05-2013 2:34 AM

 ASP.NET MVC ASP.NET MVC 
Ratings:


 1 Reply(s)
 1114  View(s)
Rate this:

here's one stupid :)

Inside my project mvc4 I have namespace

prj.MVC4.Controllers 

where I'm using Server.MapPath(..) without problem

and on

prj.MVC4.Models

Server.MapPath(...) does not exist on current context.

I'm aware that Server.MapPath resides in System.Web and both namespace and assembly are added into class with using System.Web and System.Web.dll is added to the prj.

on ctrl + . I'm getting Microsoft.SqlServer as suggested namespace to add.

How to fix this?



E E Cummings
E E Cummings

Total Post:26

Points:182
Posted on    October-05-2013 4:18 AM

Server is a property of the controller, to access it elsewhere while running a web application you can use

System.Web.HttpContext.Current.Server

Don't want to miss updates? Please click the below button!

Follow MindStick