zoukankan      html  css  js  c++  java
  • 谁能给在下指点下

    俺又来问问题了,这次不会没有人回答吧
    目前有这样一个问题,因为我的程序需要根据客户访问的URL来自动判断如何设置当前的session["language"]
    的值,开始我在 Global 中的Application_BeginRequest 中截获url来设定session,结果总出错,别人告诉我在这里不能操作session ,后来我在一个每个页面都会调用的class的构造函数中写
    if (HttpContext.Current.Session == nullreturn;
                
    string lan = HttpContext.Current.Request.ApplicationPath;
                
    //lan.Replace("/",String.Empty);
                switch( lan.ToLower() )
                
    {
                    
    case "/"  :  HttpContext.Current.Session["language"= "en-US";
                                 
    break;
                    
    case "b5" : HttpContext.Current.Session["language"= "zh-TW";
                                 
    break;
                    
    case "jp" :  HttpContext.Current.Session["language"= "en-US";
                                 
    break;
                    
    default   :  HttpContext.Current.Session["language"= "en-US";
                                 
    break;
                }
      可是 这个HttpContext.Current.Session好像永远都是null,请高人指点一二,客户催得很急的说
  • 相关阅读:
    多级别过滤器
    MongoDBAppender
    org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
    简单引入logback
    Logback configuration
    PatternLayoutEncoder 输出格式
    ConsoleAppender
    FileAppender
    Linux学习笔记
    GitLab CI/CD 学习记录
  • 原文地址:https://www.cnblogs.com/myzerg/p/187577.html
Copyright © 2011-2022 走看看