user514494
user514494

Reputation: 39

Content directory with FilePathResult

I put the file need to return in the content folder. If I want to return the file, what the path to use? Is there anyway that MVC can find reources in the content folder?

Upvotes: 0

Views: 463

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038780

No idea what content folder you are talking about but if we suppose that it is some sub directory:

public ActionResult Index()
{
    return File(Server.MapPath("~/content/foo.txt"), "text/plain");
}

where ~ indicates the root of your web site.

Upvotes: 3

Related Questions