【发布时间】:2011-04-19 02:17:58
【问题描述】:
我在http://example/image.png 有一个 ActionResult
有没有办法确定 URL 是否被请求
<img src="http://example/image.png" />
或者是从
打开的<a href="http://example/image.png" target="_blank" />
?
所以我可以用...控制结果
public ActionResult ViewPhoto()
{
if (<img src />)
{
return File();
}
else
{
return View();
}
}
【问题讨论】:
-
如果你想要不同的结果,那么也许你应该使用不同的图像?否则会产生无法维护的代码(谁会在多年后查看您的代码时知道您做了这么奇怪的事情)?
标签: c# asp.net-mvc asp.net-mvc-3 view request-headers