如何在asp.net mvc2中的控制器外部获取请求对象(How do i get a Request Object outside a controller in asp.net mvc2)

有没有办法在Html Helper方法中获取请求对象。

我想知道是否存在使用默认Image替换不存在的文件的文件。 因此,我需要Request Object和它的Method MapPath(路径)。

有人有个主意吗?

托马斯

Is there a way to get the Request Object in a Html Helper Method.

I'd like to know if a file exists to replace non existent Files with a default Image. Therefore i need the Request Object and it's Method MapPath(path).

Has anybody an idea.

Thx Thomas

最满意答案

System.Web.HttpContext.Current.Request

System.Web.HttpContext.Current.Request

如何在asp.net mvc2中的控制器外部获取请求对象(How do i get a Request Object outside a controller in asp.net mvc2)

有没有办法在Html Helper方法中获取请求对象。

我想知道是否存在使用默认Image替换不存在的文件的文件。 因此,我需要Request Object和它的Method MapPath(路径)。

有人有个主意吗?

托马斯

Is there a way to get the Request Object in a Html Helper Method.

I'd like to know if a file exists to replace non existent Files with a default Image. Therefore i need the Request Object and it's Method MapPath(path).

Has anybody an idea.

Thx Thomas

最满意答案

System.Web.HttpContext.Current.Request

System.Web.HttpContext.Current.Request