怎样下载网站模版,教程推广优化网站排名,用liferay做的网站,网站建设置顶ASP.NET APPLICATION要使用原来的ASP用户系统#xff0c;于是问题出现了#xff0c;ASP APPLICATION怎样才能让用户登录的状态及用户信息在ASP.NET中依然有效呢。于是我们考虑用构造FORM来自动提交传递ASP应用中的Session变量。例子如下ASP应用URL为http://127.0.0.1/asp/于是问题出现了ASP APPLICATION怎样才能让用户登录的状态及用户信息在ASP.NET中依然有效呢。于是我们考虑用构造FORM来自动提交传递ASP应用中的Session变量。例子如下ASP应用URL为http://127.0.0.1/asp/并在ASP.NET应用中的web.config设定 !--设定ASP应用的URL-- add keyaspURL valuehttp://127.0.0.1/asp/ /在ASP应用中增加两个ASP页面system.asp和autoPostForm.asp!--system.asp--%Session(UID)user session(isPass)ok Server.Transfer(autoPostForm.asp)%!--autoPostForm.asp--%Response.Write(form namet idt actionhttp://127.0.0.1/aspdotnet/getSession.aspxmethodpost )Response.Write(input typehidden nameUID )Response.Write( value Session(UID) )Response.Write(input typehidden nameisPass )Response.Write( value Session(isPass) )Response.Write(/form)Response.Write(scriptt.submit();/script)%在ASP.net应用中用页面getSession.aspx来接受传递过来的Session变量值getSession.aspx.cs代码片段private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { string aspurlConfigurationSettings.AppSettings[aspURL].Trim(); try { string fromurlRequest.ServerVariables[HTTP_REFERER]; //验证是否从asp应用中提交过来 if(fromurl.StartsWith(aspurl)) { string uidRequest[UID].ToString(); string stateRequest[isPass].ToString(); if(uid! stateok) { //表明用户在asp系统中已登录成功 } } else { Response.Write(scriptalert(非法用户或未登录用户);top.location.href aspurl ;/script); } } catch { Response.Redirect(aspurl); } }}当然上述例子只是为解决特定的问题如果要写成通用的则需要做如下修改就在autoPostForm.asp使用 For each sItem in Session.Contents Response.Write(input typehidden name sItem) Response.Write( value Session.Contents(sitem) ) next 而在getSession.aspx页面用下面的代码来接受并用同名Session变量保存 for(int i0;iRequest.Form.Count;i) { Session[Request.Form.GetKey(i)]Request.Form[i].ToString(); } 转载于:https://www.cnblogs.com/top5/archive/2010/08/06/1794086.html