<small id='TnXiu'></small><noframes id='TnXiu'>

  1. <i id='TnXiu'><tr id='TnXiu'><dt id='TnXiu'><q id='TnXiu'><span id='TnXiu'><b id='TnXiu'><form id='TnXiu'><ins id='TnXiu'></ins><ul id='TnXiu'></ul><sub id='TnXiu'></sub></form><legend id='TnXiu'></legend><bdo id='TnXiu'><pre id='TnXiu'><center id='TnXiu'></center></pre></bdo></b><th id='TnXiu'></th></span></q></dt></tr></i><div id='TnXiu'><tfoot id='TnXiu'></tfoot><dl id='TnXiu'><fieldset id='TnXiu'></fieldset></dl></div>

    1. <legend id='TnXiu'><style id='TnXiu'><dir id='TnXiu'><q id='TnXiu'></q></dir></style></legend>
        <bdo id='TnXiu'></bdo><ul id='TnXiu'></ul>

      <tfoot id='TnXiu'></tfoot>

      ASP 到 ASP.NET 会话变量

      ASP to ASP.NET Session Variables(ASP 到 ASP.NET 会话变量)
      <i id='bLKY3'><tr id='bLKY3'><dt id='bLKY3'><q id='bLKY3'><span id='bLKY3'><b id='bLKY3'><form id='bLKY3'><ins id='bLKY3'></ins><ul id='bLKY3'></ul><sub id='bLKY3'></sub></form><legend id='bLKY3'></legend><bdo id='bLKY3'><pre id='bLKY3'><center id='bLKY3'></center></pre></bdo></b><th id='bLKY3'></th></span></q></dt></tr></i><div id='bLKY3'><tfoot id='bLKY3'></tfoot><dl id='bLKY3'><fieldset id='bLKY3'></fieldset></dl></div>

        <small id='bLKY3'></small><noframes id='bLKY3'>

            <tfoot id='bLKY3'></tfoot>

            • <bdo id='bLKY3'></bdo><ul id='bLKY3'></ul>
              <legend id='bLKY3'><style id='bLKY3'><dir id='bLKY3'><q id='bLKY3'></q></dir></style></legend>

                  <tbody id='bLKY3'></tbody>
                本文介绍了ASP 到 ASP.NET 会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我们有一个经典 ASP 网站,我们正在根据需要慢慢迁移到 ASP.NET.

                We have a website in classic asp that we are slowly migrating to ASP.NET as necessary.

                问题当然是经典的 asp 和 ASP.NET 是如何处理 Sessions 的.在花了最后几个小时研究网络之后,我发现了很多文章,但没有一篇比其他文章更突出.

                The problem of course is how classic asp and ASP.NET handle Sessions. After spending the last few hours researching the web, I found many articles, but not one that stood out over the others.

                是否有在经典 asp 和 asp.net 之间传输会话变量的最佳实践?安全性是必须的,非常感谢任何带有示例的解释.

                Is there a best practice for transferring session variables from and to classic asp and asp.net? Security is a must and any explanation with examples is much appreciated.

                推荐答案

                将单个会话变量从经典 asp 传递到 .net 服务器端(对客户端隐藏会话值)的简单桥接器是这样的:

                A simple bridge to pass a single session variable from classic asp to .net serverside (hiding your sessionvalue from the client), would be this:

                • 在 ASP 端:输出会话的 asp 页面,例如调用它.asp2netbridge.asp

                • On the ASP end: An asp page to output your session, call it e.g. asp2netbridge.asp

                <%
                'Make sure it can be only called from local server '
                if (request.servervariables("LOCAL_ADDR") = request.servervariables("REMOTE_ADDR")) then
                    if (Request.QueryString("sessVar") <> "") then
                        response.write Session(Request.QueryString("sessVar"))
                    end if
                end if
                %>
                

              • 在 .net 端,远程调用该 asp 页面.:

              • On the .net end, a remote call to that asp page. :

                private static string GetAspSession(string sessionValue)
                 {
                    HttpWebRequest _myRequest = (HttpWebRequest)WebRequest.Create(new Uri("http://yourdomain.com/asp2netbridge.asp?sessVar=" + sessionValue));
                    _myRequest.ContentType = "text/html";
                    _myRequest.Credentials = CredentialCache.DefaultCredentials;
                    if (_myRequest.CookieContainer == null)
                        _myRequest.CookieContainer = new CookieContainer();
                    foreach (string cookieKey in HttpContext.Current.Request.Cookies.Keys)
                    {
                        ' it is absolutely necessary to pass the ASPSESSIONID cookie or you will start a new session ! '
                        if (cookieKey.StartsWith("ASPSESSIONID")) {
                            HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieKey.ToString()];
                            _myRequest.CookieContainer.Add(new Cookie(cookie.Name, cookie.Value, cookie.Path, string.IsNullOrEmpty(cookie.Domain)
                                ? HttpContext.Current.Request.Url.Host
                                : cookie.Domain));
                        }
                    }
                    try
                    {
                        HttpWebResponse _myWebResponse = (HttpWebResponse)_myRequest.GetResponse();
                
                        StreamReader sr = new StreamReader(_myWebResponse.GetResponseStream());
                        return sr.ReadToEnd();
                    }
                    catch (WebException we)
                    {
                        return we.Message;
                    }
                }
                

              • 这篇关于ASP 到 ASP.NET 会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Problem getting list box items added through jquery in code behind(在后面的代码中通过 jquery 添加列表框项目时出现问题)
                Selected item in list box is null(列表框中的选定项为空)
                ASP.NET: Listbox datasource and databind(ASP.NET:列表框数据源和数据绑定)
                ASP:ListBox Get Selected Items - One Liner?(ASP:ListBox 获取选定的项目 - 一个衬里?)
                Maintain scroll position in listboxes in updatepanels, NOT the page(在更新面板的列表框中保持滚动位置,而不是页面)
                Moving items in Dual Listboxes(在双列表框中移动项目)

                  <bdo id='Y5qBb'></bdo><ul id='Y5qBb'></ul>

                  • <legend id='Y5qBb'><style id='Y5qBb'><dir id='Y5qBb'><q id='Y5qBb'></q></dir></style></legend>
                  • <small id='Y5qBb'></small><noframes id='Y5qBb'>

                      <tfoot id='Y5qBb'></tfoot>
                            <tbody id='Y5qBb'></tbody>
                          <i id='Y5qBb'><tr id='Y5qBb'><dt id='Y5qBb'><q id='Y5qBb'><span id='Y5qBb'><b id='Y5qBb'><form id='Y5qBb'><ins id='Y5qBb'></ins><ul id='Y5qBb'></ul><sub id='Y5qBb'></sub></form><legend id='Y5qBb'></legend><bdo id='Y5qBb'><pre id='Y5qBb'><center id='Y5qBb'></center></pre></bdo></b><th id='Y5qBb'></th></span></q></dt></tr></i><div id='Y5qBb'><tfoot id='Y5qBb'></tfoot><dl id='Y5qBb'><fieldset id='Y5qBb'></fieldset></dl></div>