如何在控制器操作方法内部获取文件路径?

时间:2012-09-02 10:17:59

标签: asp.net-mvc asp.net-mvc-3

我见过以下代码:

    protected override void Initialize(RequestContext requestContext)
    {
        base.Initialize(requestContext);
        var filePath = requestContext.HttpContext.Request.FilePath;
    }

但是,从ASP MVC中的action方法内部有更简单的方法吗?

例如www.test.com/abc我想得到“/ abc”

1 个答案:

答案 0 :(得分:1)

非常直接。

public ActionResult Foo()
{
     var filePath = Request.FilePath;

     //other stuff
}
相关问题