Asp.net mvc 具有FilePathResult的内容目录

Asp.net mvc 具有FilePathResult的内容目录,asp.net-mvc,asp.net-mvc-2,Asp.net Mvc,Asp.net Mvc 2,我把需要返回的文件放在内容文件夹中。如果我想返回文件,使用什么路径?MVC是否可以在内容文件夹中找到资源?不知道您在说什么内容文件夹,但如果我们假设它是某个子目录: public ActionResult Index() { return File(Server.MapPath("~/content/foo.txt"), "text/plain"); } 其中~表示您网站的根目录。不知道您在谈论什么内容文件夹,但如果我们假设它是某个子目录: public ActionResult In

我把需要返回的文件放在内容文件夹中。如果我想返回文件,使用什么路径?MVC是否可以在内容文件夹中找到资源?

不知道您在说什么内容文件夹,但如果我们假设它是某个子目录:

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

其中
~
表示您网站的根目录。

不知道您在谈论什么内容文件夹,但如果我们假设它是某个子目录:

public ActionResult Index()
{
    return File(Server.MapPath("~/content/foo.txt"), "text/plain");
}
其中
~
表示网站的根目录