HttpContext.Current.Session为空请求图像。为什么? [英] HttpContext.Current.Session is null requesting images. Why?

查看:318
本文介绍了HttpContext.Current.Session为空请求图像。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个ASP MVC应用程序。

I'm building a ASP MVC application.

当我请求路由到控制器,例如:

When I request a route to a controller, for example:

http://myserver/sales/id/5

会话对象 HttpContext.Current.Session 工作完美。

然而,当我请求图像或脚本,例如:

However, when I'm requesting an image or a script, for example:

http://myserver/Scripts/jquery-1.4.1.js

会话对象 HttpContext.Current.Session

如何在没有真正的会话(例如首次登录),我可以区分其他的这种情况呢?

How I can distinguish this situation from other when there is no "real" session (for example first login)?

推荐答案

为什么需要检索一个静态文件的会话?

Why would you need a session for retrieving a static file?

除非你使用的是动态的处理程序,绝对不需要会话获取这些内容。

Unless you are using a dynamic handler, there is absolutely no need for session to retrieve such content.

我的观点是,会议不提供用于检索静态内容有任何用处,所以它是不可用的。

My point is that session does not serve any useful purpose for retrieving static content, so it is not available.

这篇关于HttpContext.Current.Session为空请求图像。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆