ÔÚWeb ServiceÖÐʹÓÃASP.net״̬±£³Ö
ÔÌûµØÖ·£ºhttp://www.wangchao.net.cn/bbsdetail_572426.html
¼ò½é
¡¡¡¡ÓÐÐí¶à´ÏÃ÷µÄ°ì·¨¿ÉÒÔ½â¾öHTTPÐÒéµÄÎÞ״̬ÎÊÌ⣬ÀýÈç¶Ôÿ¸öÇëÇóÖظ´·¢ËÍÓ¦ÓóÌÐòÊý¾Ý°ü¡¢Ê¹ÓÃHTTPÈÏÖ¤»úÖÆÀ´½«ÇëÇóÓ³Éäµ½Ìض¨µÄÓû§¡¢Ê¹ÓÃCookieÀ´´æ´¢Ò»ÏµÁÐÇëÇóµÄ״̬µÈ¡£ÔÚASP.net¼¼ÊõÖÐÌṩÁËÒ»¸ö·Ç³£ÓÐЧµÄ·½°¸À´±£³Ö״̬£¬¸Ã·½°¸Òþ²ØÁËËùÓиßÄѶȵģ¬¾ßÓÐÌôÕ½ÐԵŤ×÷µÄϸ½Ú£¬Óû§Ö»Ðè¼òµ¥µØʹÓÃSystem.Web.SessionState.HttpSessionStateÀࡣͬʱ£¬ÄãÒ²¿ÉÒÔÏñÔÚASP.net³ÌÐòµØWebÒ³Ã棨.aspx£©ÖÐÒ»ÑùÔÚWeb ServiceµÄ·½·¨ÖÐʹÓÃÕâ¸öÀֻ࣬ÓÐÒ»µãССµÄ²»Í¬¡£
¡¡¡¡ASP.netµÄSession¶ÔÏó¸ÅÊö
¡¡¡¡ASP.netµÄSession״̬ÐÅÏ¢ÔÚ¸ù±¾ÉÏͨ¹ýÁ½¸ö»úÖƱ£³Ö¡£ÆäÒ»ÊÇʹÓÃCookie¡£µ±¿Í»§¶Ë·¢ËÍÒ»¸öÇëÇóµ½·þÎñÆ÷¶Ëʱ£¬·þÎñÆ÷½«·¢»ØÒ»¸ö¸½¼ÓHTTP Set-CookieÍ·µÄÏìÓ¦ÐÅÏ¢£¬¶øCookieµÄÖµ¾ÍÊÇÒÔ¼ü/Öµ¶ÔµÄÐÎʽ±£´æÔÚ¸ÃÐÅÏ¢Àï±ß¡£ÔÚ¶Ôͬһ·þÎñÆ÷µÄËùÓеÄͬ²½ÇëÇóÖУ¬¿Í»§¶ËÔÚHTTP CookieÍ·Öз¢ËÍCookie¼ü/Öµ¶Ô¡£È»ºó·þÎñÆ÷¿ÉÒÔ½«²¢·¢µÄÇëÇóͬ³õʼµÄÇëÇó¶ÔÓ¦ÆðÀ´¡£ASP.netʹÓÃÒ»¸ö±£´æ»á»°µÄIDµÄcookieÀ´±£³Ö»á»°×´Ì¬¡£¸ÃID±êʶ±»ÓÃÀ´ÎªÌض¨µÄÓû§ÕÒµ½ÓëÆä¶ÔÓ¦µÄHttpSessionStateÀàµÄʵÀý¡£ÀàHttpSessionState½ö½öÌṩÁËÒ»¸öͨÓõÄÊý¾Ý¼¯£¬Äã¿ÉÒÔÔÚÆäÖб£´æÄãÐèÒªµÄÈκÎÐÅÏ¢¡£
¡¡¡¡ASP.netÓÃÀ´±£³Ö״̬µÄÁíÍâÒ»¸ö»úÖƹ¤×÷ʱÎÞÐëʹÓÃCookie¡£Ò»Ð©ä¯ÀÀÆ÷±»Óû§ÉèÖÃΪ½ûֹʹÓÃcookie»òÕ߸ɴà¾Í²»Ö§³ÖCookie,ASP.netÌṩÁËÒ»ÖÖ»úÖÆÀ´½â¾öÕâ¸öÎÊÌ⣬ËüµÄÖ÷ÒªÔÀíÊǽ«Ò»¸öÇëÇóÖض¨Ïòµ½Ò»¸ö°üº¬ASP.net״̬IDµÄURL¡£µ±¸ÃÇëÇó±»½ÓÊܵ½Ê±£¬Õâ¸öǶÔÚURLÖеÄID±»½ØÈ¡ÏÂÀ´£¬·þÎñÆ÷ͨ¹ý¸ÃIDÕÒµ½ºÏÊʵÄHttpSessionStateÀàµÄʵÀý¡£ÕâÖÖ·½Ê½ÔÚHTTPÐÒéµÄʹÓÃGET·½Ê½µÄÇëÇóÖй¤×÷µÄºÜºÃ£¬µ«ÊÇÔÚ.netµÄXML Web Service´úÂëÖлá³öÏÖÎÊÌâ¡£
¡¡¡¡±ØÐëÖ¸³öµÄÊÇ£¬ÓÐЩʱºò°ÑÐÅÏ¢Ö±½Ó´æ´¢ÔÚCookieÖÐÒª±È´æ´¢ÔÚSessionÖиüºÃ¡£±ÜÃâʹÓÃSession¿ÉÒÔ½ÚÊ¡·þÎñÆ÷×ÊÔ´£¬¶øÇÒÄãÒ²ÎÞÐ뿼ÂÇһЩ·³È˵ÄÎÊÌ⣬±ÈÈ綨λһ¸öÌض¨µÄSession¶ÔÏó¡¢Session¶ÔÏóÒòΪÇëÇóµÄ³¤Ê±¼äµÄÑÓ³Ù¶ø±»ÒƳý»òÕßÔÚ·þÎñÆ÷ÉÏû±ØÒªµØ±£ÁôÖ±µ½¹ýÆÚ¡£È»¶ø£¬Èç¹ûÄãÓÐһЩ°üº¬Ä㲻ϣÍûÓëÄãÌṩµÄ·þÎñµÄʹÓÃÕß¹²ÏíµÄÖ´ÐÐÐÅÏ¢£¬»òÕßÓÐһЩÄ㲻ϣÍûͨ¹ýδ¼ÓÃܵÄÐŵÀ´«ÊäµÄ˽ÓÐÊý¾Ý£¬»òÕßÄãÈÏΪ½«ÕâЩÊý¾Ý²åÈëHTTPÐÒéÍ·ÖÐÊDz»ÇÐʵ¼ÊµÄ£¬ÄÇôÄã¾ÍÓ¦¸ÃʹÓ
Ïà¹ØÎĵµ£º
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using Sy ......
ÕâÒ²ÐíÊÇÒ»¸öСÎÊÌâ µ«ÊÇÓкܶàѧÎÊ ²»ÄÜÑÛ¸ßÊÖµÍ ÎҰѴ󲿷ÖÇé¿öÁгöÀ´ ¸ø´ó¼ÒÒ»¸öÌáÐÑ
float str = 987654.32F;
//Response.Write(string.Format("{0:c}", str));
//this.Label1.Text = string.Format("{0:D}", str);
//this.Label1.Text = string.Format("{0:C}", str); ......
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.location.href=document.URL; < /script&g ......
¸ßЧʹÓÃʹÓÃSQL»º´æÒÀÀµ
ASP.NET FrameworkÐÂÔöµÄÒ»¸ö·Ç³£Ç¿´óµÄ¹¦ÄÜÊÇSQL»º´æÒÀÀµ¡£¸Ã¹¦ÄÜÔÊÐíµ×²ãÊý¾Ý¿âÖеÄÊý¾ÝÐÞ¸Äʱ£¬×Ô¶¯µØÖØÐÂÔØÈ뻺´æµÄÊý¾Ý¡£
ÔÚʹÓþø¶Ô»º´æ¹ýÆÚ²ßÂÔ»òÕßµ¯ÐÔ»º´æ¹ýÆÚ²ßÂÔʱÓÐÒ»¸öȨºâ£¬¶ÔÓÚÐÔÄܺͳ¾ÉÊý¾ÝµÄȨºâ¡£ÀýÈ磬Èç¹ûÔÚÄÚ´æÖлº´æÊý¾Ý20Ã룬ÔòÕâ20ÃëÄÚÏÔʾµÄÊý¾Ý¿ÉÄÜÊǹ ......