ÓÃASP.Net FormsģʽʵÏÖWebServiceÉí·ÝÑéÖ¤
ÔÚ°²È«ÐÔÒªÇó²»ÊǺܸߵÄASP.Net³ÌÐòÖУ¬»ùÓÚFormsµÄÉí·ÝÑéÖ¤ÊǾ³£Ê¹ÓõÄÒ»ÖÖ·½Ê½£¬¶øÈç¹ûÐèÒª¶ÔWebService½øÐÐÉí·ÝÑéÖ¤£¬×î³£ÓõĿÉÄÜÊÇ»ùÓÚSoap ±êÍ·µÄ×Ô¶¨ÒåÉí·ÝÑéÖ¤·½Ê½¡£Èç¹û¶ÔÁ½Õß×öһϱȽϵĻ°£¬ÏÔÈ»£¬»ùÓÚFormsµÄÑéÖ¤·½Ê½¸ü¼Ó·½±ãÒ×Óã¬ÄÜ·ñ½«FormsÑéÖ¤·½Ê½Ó¦Óõ½WebServiceÖÐÈ¥ÄØ£¿
´ÓÀíÂÛÉϽ²£¬Ê¹ÓûùÓÚFormsµÄ·½Ê½¶ÔWebService½øÐÐÉí·ÝÑéÖ¤ÊÇ¿ÉÐеģ¬µ«ÊÇʹÓùý³ÌÖлá´æÔÚÒÔÏÂÁ½¸öÎÊÌ⣺
¡¡¡¡1.»ùÓÚFormsµÄÑéÖ¤·½Ê½Í¬Ê±Ò²ÊÇ»ùÓÚCookieµÄÑéÖ¤·½Ê½£¬ÔÚʹÓÃä¯ÀÀÆ÷ʱ£¬Õâ¸öÎÊÌâÊDz»ÐèÒªÎÒÃÇ¿¼Âǵġ£µ«¶ÔÓÚʹÓÃWebServiceµÄÓ¦ÓóÌÐòÀ´Ëµ£¬Ä¬ÈÏÊDz»Äܱ£´æCookieµÄ£¬ÐèÒªÎÒÃÇ×Ô¼ºÈ¥×öÕâ¸ö¹¤×÷¡£
¡¡¡¡2.WebService¼ÈÈ»ÊÇÒ»¸öA2A(Application To Application)Ó¦ÓóÌÐò£¬Ê¹ÓÃWeb±íµ¥½øÐÐÉí·ÝÑéÖ¤ÏÔÈ»²»Ì«ºÏÊÊ£¬¶øÇÒ£¬Õ⽫²»¿É±ÜÃâµÄÔì³ÉÈË»ú½»»¥£¬Ê¹WebServiceµÄÓ¦Óôó´òÕÛ¿Û¡£
½ÓÏÂÀ´£¬ÎÒÃǾͷֲ½½â¾öÕâÁ½¸öÎÊÌ⣺
¡¡¡¡1.CookieµÄ±£´æÎÊÌâ
WebServiceµÄ¿Í»§¶Ë´úÀíÀàÓÐÒ»¸öÊôÐÔCookieContainer¿ÉÓÃÓÚÉèÖûò»ñÈ¡Cookie¼¯ºÏ£¬±£´æCookieµÄÈÎÎñ¾Í½»¸øËûÁË£º
System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer();
MyService.WebService service = new App.MyService.WebService();
service.CookieContainer = cookieContainer;
¡¡¡¡2.ÎÒÃDz»ÏëʹÓÃWeb±íµ¥½øÐÐÉí·ÝÑéÖ¤£¬ÐÒÔ˵ÄÊÇ£¬ASP.Net±íµ¥ÑéÖ¤ÖÐµÄ±íµ¥Ò³£¨¼´Web.configÎļþÖÐ forms ÔªËØÄÚµÄloginUrl£©Í¬Ñù¿ÉÒÔÖ¸¶¨ÎªWebServiceÎļþ¡£
ÎÒÃÇ´´½¨Ò»¸öרÃÅÓÃ×÷Éí·ÝÑéÖ¤µÄWeb·þÎñ£¬ÔÝÇÒÃüÃûΪLogin.asmx£¬È»ºóÈà loginUrl µÈÓÚ “Login.asmx”£¬µ±È»£¬»¹ÐèÒªÔÚWeb.configÎļþÖÐµÄ authorization ½ÚÖнûÖ¹ÄäÃû·ÃÎÊ£¨·ñÔòÎÒÃǿɾͰ×æ»îÁË£©£¬Íê³ÉÅäÖúóµÄWeb.configÎļþÈçÏ£º
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="false" />
<authentication mode="Forms">
<forms name="MyService" loginUrl="Login.asmx"></forms>
</authentication>
<authorization >
Ïà¹ØÎĵµ£º
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web ......
ºÜ½üûÓÐʹÓÃ.netÁË£¬²»ÖªÊǼÇÒäÁ¦²»ÐÐÁË£¬»¹ÊÇʲôµÄ£¬iframeµÄÓ÷¨¶¼Íü¼ÇÁË£¬ÔÚÉè¼ÆurlÌøתtargetµÄʱºò×ÜÊDz»³É¹¦¡£ÓôÃÆÁËÎÒ£¬ÍøÉÏËÑË÷ÁËÒ»Õó»¹ÊÇûÓз¢ÏÖÊÇÔõô»ØÊ£¬ºóÀ´¸É´à¿´ÒÔÇ°µÄwebÒ³Ã棬ÕÒÁ˺þã¬ÖÕÓÚÕÒµ½£¬ÔÀ´ÔÚÉè¼ÆiframeµÄʱºò£¬²»½öÐèÒªid£¬¸üÐèÒªnameÊôÐÔ£¬¶øvsÖÐÌṩµÄiframeÊôÐÔûÓÐname,ËùÒÔº¦ÎÒæ»îÁ ......
ASP.NETÒ³ÃæÓëIISµ×²ã½»»¥ºÍ¹¤×÷ÔÀíÏê½â
µÚÒ»»Ø£º
ÒýÑÔ
ÎÒ²éÔĹý²»ÉÙAsp.NetµÄÊé¼®£¬·¢ÏÖ´ó¶àÊý×÷Õ߶¼ÊÇÕ¾ÔÚÒ»¸ö±È½Ï¸ßµÄ²ã´ÎÉϽ²½âAsp.Net¡£ËûÃÇÄÍÐÄ¡¢Ï¸ÖµظæËßÄãÈçºÎÒ»²½²½ÍϷſؼþ¡¢ÉèÖÿؼþÊôÐÔ¡¢±àдCodeBehind´úÂ룬ÒÔʵÏÖij¸öÌض¨µÄ¹¦ÄÜ¡£
ÕâÖÖ×ö·¨£¬Êµ¼ÊÉÏÊǻشðÁË“ÈçºÎÈ¥×ö”µÄÎÊÌ⣬ȴà ......
´ÓÊý¾Ý¿âÈ¡³öÊý¾ÝÈ»ºó¶¯Ì¬µÄÉú³Éhtml¾²Ì¬Ò³Ãæ¡£ÕâÖÖ¼¼ÊõÌرðÊÇÔÚÓµÓдóÁ¿Ò³ÃæµÄÍøÕ¾ÖÐÏÔµÄÌرðµÄÖØÒª
¾ßÌå²½ÖèÎÒÏêϸµÄдһÏÂ
1.½¨Á¢¾²Ì¬Ä£°åÒ³Ãæ¡£Ò²¾ÍÊǽ¨Á¢ÆðÄ£°åÒ³ÃæµÄ¼Ü¹¹
2.È»ºó´Óºǫ́Êý¾Ý¿âÖÐÌáÈ¡ÄÚÈÝ£¬½øÐÐÌæ»»
3.°ÑÌæ»»ºóµÄ×Ö·û´®Ð´ÈëÖÐ
ÎÒÒ²°´ÕÕÉÏÃæµÄ˳Ðò×öһϰÉ
Ê×ÏȽ¨Á¢Ò»¸öÄ£°åHtmlÈ¡ÃûModelHtml.htm. ......
Page.ResponseÊôÐÔÖ»ÓÐÔÚÒ³Ãæ´úÂëÖУ¬»òÕß˵Ôڼ̳Ð×Ô: System.Web.UI.PageµÄÀàÖвÅÓС£ÆäËû¼´Ê¹using System.Web.UI Ò²ÎÞ·¨Ê¹ÓÃPage.ResponseÊôÐÔ¡£·ñÔò±àÒëʱ±¨´í£ºµ±Ç°ÉÏÏÂÎÄÖв»´æÔÚÃû³Æ"Response"
½â¾ö·½·¨£º¿ÉÒÔÓÃSystem.Web.HttpContext.Current.Res ......