How return 304 status with FileResult in ASP.NET MVC RC1

前端 未结 3 1303
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 16:03

As you may know we have got a new ActionResult called FileResult in RC1 version of ASP.NET MVC.

Using that, your action methods can ret

3条回答
  •  甜味超标
    2021-02-05 16:51

    Don't use 304 with FileResult. From the spec:

    The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.

    It's not clear what you're trying to do from your question. The server doesn't know what the browser has in its cache. The browser decides that. If you're trying to tell the browser not to re-fetch the image when needed again if it already has a copy, set the response Cache-Control header.

    If you need to return 304, use EmptyResult instead.

提交回复
热议问题