ABCDD ABCDD - 2 months ago 6
C# Question

call Controller function from Model class

I need to use Controller's

method to get the path for the app data to access them from a model class. So if i create this function in HomeController:

public string getPathls()
string path = HttpContext.Server.MapPath("~/App_Data/Folder/");
return path;

how can I call it from a model class like this:

string pathi = Project.Controllers.HomeController....//what next?


I used this and it Wooooorks! I can call it from Model and it gets the path

var pathi = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Temps/file.xml");

            string ff = pathi.ToString();