生成验证码页面:yanzhen.aspx.cs
ystem.Random a = new Random(System.DateTime.Now.Millisecond);
Int32 A = a.Next(10, 30);
Int32 B = a.Next(1, 20);
String jieguo = (A + B).ToString();
//写入Session
Session["CheckCode"] = jieguo;
需要取得session值的页面怎么取这个啊,我用 String yanzhen = HttpContext.Current.Session["CheckCode"].ToString(); 运行的时候提示错误:
用户代码未处理 System.NullReferenceException
Message="未将对象引用设置到对象的实例。"
Source="web2"
StackTrace:
在 web2.userreg..ctor() 位置 D:\web2\web2\userreg.aspx.cs:行号 26
在 ASP.userreg_aspx..ctor() 位置 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\21c64b4e\b657b993\App_Web_cbhpdmny.1.cs:行号 0
在 __ASP.FastObjectFactory_app_web_cbhpdmny.Create_ASP_userreg_aspx() 位置 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\21c64b4e\b657b993\App_Web_cbhpdmny.3.cs:行号 0
在 System.Web.Compilation.BuildResultCompiledType.CreateInstance()
在 System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
在 System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
在 System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
在 System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
在 System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
InnerException: