asp.net¿Í»§¶Ë½Å±¾µ÷ÓÃwebservice
ÓÉÓÚ asp.net ajax ·â×°Á˺ܶàºÜºÃµÄ·½·¨£¬ËùÒÔʹÓÃÕâ¸ö¿ò¼Üµ÷ÓÃwebwervice±äµÄ·Ç³£¼òµ¥¡£
µÚÒ»²½
webservice ÀàµÄ·½·¨ÐèÒªÓÐscriptServiceµÄ attribute.
namespace ServiceTest
{
/// <summary>
///WebService µÄժҪ˵Ã÷
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
//ÈôÒªÔÊÐíʹÓà ASP.NET AJAX ´Ó½Å±¾Öе÷ÓÃ´Ë Web ·þÎñ£¬ÇëÈ¡Ïû¶ÔÏÂÐеÄ×¢ÊÍ¡£
// [System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService
{
public MyWebService()
{
//Èç¹ûʹÓÃÉè¼ÆµÄ×é¼þ£¬ÇëÈ¡Ïû×¢ÊÍÒÔÏÂÐÐ
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
µÚ¶þ²½
ÔÚ¿Í»§¶ËʹÓÃscriptmanagerÀ´ ÉèÖÃwebserviceµÄ·¾¶
<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug">
<Services>
<asp:ServiceReference Path="WebServiceFoundation.asmx" InlineScript="true" />
</Services>
</asp:ScriptManager>
µÚÈý²½
½Å±¾µ÷ÓÃ
ÃüÃû¿Õ¼ä.ÀàÃû.·½·¨Ãû (»Øµ÷·½·¨);
<mce:script language="javascript"><!--
function callWebService()
{
ServiceTest.MyWebService.HelloWorld(getResult);
}
function getResult(result)
{
alert(result);
}
// --></mce:script>
µ±µ÷Óà webserviceÊdzöÏÖ´íµÄ´¦Àí¡£
Õâ¸öÆäʵÊÇ·â×°ºÃµÄ¡£
¿ò¼ÜÉú³ÉµÄ¿Í»§¶Ë½Å±¾Óм¸¸ö²ÎÊý
Ö»Òª½«Õ⼸¸ö»Øµ÷º¯ÊýÉèÖúþÍok ÁËÔڻص÷º¯ÊýÖд¦Àí´íÎó
Ïà¹ØÎĵµ£º
ASP.NetÉú³É¾²Ì¬HTMLÒ³!
»·¾³:Microsoft .NET Framework SDK v1.1
OS:Windows Server 2003 ÖÐÎÄ°æ
ASP.NetÉú³É¾²Ì¬HTMLÒ³
ÔÚAspÖÐʵÏÖµÄÉú³É¾²Ì¬Ò³Óõ½µÄFileSystemObject¶ÔÏó!
ÔÚ.NetÖÐÉæ¼°´ËÀà²Ù×÷µÄÊÇSystem.IO
ÒÔÏÂÊdzÌÐò´úÂë ×¢:´Ë´úÂë·ÇÔ´´!²Î¿¼±ðÈË´úÂë
//Éú³ÉHTMLÒ³
public static bool W ......
1.¹Ø±Õ²»±ØÒªµÄSession
<%@ Page EnableSessionState="flase"%>
2.¹Ø±Õ²»±ØÒªµÄViewState
<asp:DataGrid EnableViewState="false" runat="server">
Èç¹ûÒ³Ã漶
<%@ Page EnableViewState="false"%>
3.²»ÒªÊ¹ÓÃException¿ØÖƳÌÐòÁ÷³Ì
ExceptionÊǺܺÄ×ÊÔ´µÄ
4.½ûÓÃVBºÍJScript¶¯Ì¬Êý ......
1£®URL´«Öµ
ÕâÊǾµäµÄ´«Öµ·½Ê½£¬ÕâÖÖ·½·¨µÄʹÓ÷dz£¼òµ¥£¬²»¹ýËù´«µÝµÄÖµÊÇ»áÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸Éϵģ¬¶øÇÒ²»ÄÜ´«µÝ¶ÔÏó¡£ËùÒÔÕâÖÖ·½·¨Ò»°ãÓÃÓÚ´«µÝµÄÖµÉÙÇÒ°²È«ÐÔÒªÇ󲻸ߵÄÇé¿öÏ¡£ÔÚ*.aspxÒ³Ã濪·¢ÖпÉÒÔʹÓ󬼶Á´½ÓÎı¾½øÐд«Öµ
2£®Session´«Öµ
ÕâÖÖ·½·¨½«Ã¿·ÝÊý¾Ý´æ´¢ÓÚ·þÎñÆ÷±äÁ¿ÖУ¬¿ÉÒÔ´«µÝ±È½Ï¶àµÄÊý¾Ý£¬²¢ ......
ASP.NETÉú³ÉËæ»úÃÜÂë
ÔÚ¿ª·¢ÐèÒªÓû§×¢²áºó²ÅÄÜʹÓÃÌṩµÄ¸÷ÏÄܵÄÓ¦ÓóÌÐòʱ£¬ÔÚÐÂÓû§Ìá½»×¢²áÐÅÏ¢ºó£¬½Ï³£¼ûµÄ×ö·¨ÊÇÓɳÌÐòÉú³ÉËæ»úÃÜÂ룬Ȼºó·¢ËÍÃÜÂëµ½Óû§×¢²áʱÌîдµÄµç×ÓÐÅÏ䣬Óû§ÔÙÓÃÊÕµ½µÄÃÜÂëÀ´¼¤»îÆäÕÊ»§¡£
ʵÏÖASP.NETÉú³ÉËæ»úÃÜÂ빦ÄÜÊǺÜÈÝÒ׵ģ¬ÏÂÃæµÄ´úÂë¸ø³öÁËÍêÕûµÄʵÏÖ·½·¨£º
publicstatic ......
·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔÀ´ÊäÈëµÄÊý¾Ý½øÐÐÐ޸ĻòÕ߸üÐÂʱÓõģ¬»òÕßÊÇÒòΪÍøվΪÁË·½±ãä¯ÀÀÕ߶øÓÐÐÄÌí¼ÓµÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.NETÖж¼ÊÇÓÃÒ»¸öButton¿Ø¼þÀ´ÊµÏֵģ¬ÊµÏֵķ½·¨Óкܶ࣬½ñÌìÇ¡ºÃÔÚ×öÏîĿʱÅöµ½ÒªÓÃÕâ¸ö¶«¶«£¬ÎҾͰÑÄÜʵÏÖ" ·µ» ......