ת£ºÔÚASP.NETÖÐÔÚ²»Í¬Ò³Ãæ¼ä½øÐÐÊý¾Ý´«µÝÓÐÄÄЩ·½·¨
Ëѵģ¬ÍøÂçºÜÇ¿´óµÄ
1. Get(¼´Ê¹ÓÃQueryStringÏÔʽ´«µÝ)
·½Ê½£ºÔÚurlºóÃæ¸ú²ÎÊý¡£
ÌØµã£º¼òµ¥¡¢·½±ã¡£
ȱµã£º×Ö·û´®³¤¶È×Ϊ255¸ö×Ö·û£»Êý¾Ýй©ÔÚurlÖС£
ÊÊÓÃÊý¾Ý£º¼òµ¥¡¢ÉÙÁ¿¡¢¹Ø¼üµÄÊý¾Ý¡£
ÊÊÓ÷¶Î§£º´«µÝ¸ø×Ô¼º¡¢´«µÝ¸øÁíÒ»¸öÄ¿±êÒ³Ãæ£»³£ÓÃÓÚ2¸öÒ³Ãæ¼ä´«µÝÊý¾Ý¡£
Ó÷¨£ºÀýÈ磺urlºó¼Ó?UserID=…£¬Ìø×ªµ½Ä¿±êÒ³Ãæ£¬Ä¿±êÒ³ÃæÔÚËÅ·þ¶Ë¿ÉÓÃRequest.QueryString["InputText"]»ñÈ¡ÆäÖ¸¶¨²ÎÊýÖµ¡£
2. Post
·½Ê½£ºÍ¨Óõķ½Ê½¡£ÀûÓÃformÌá½»¡£
ÌØµã£º×î³£Óõķ½·¨¡£³£Óü¼ÇÉÊǰÑÒþÃØµÄÊý¾Ý´æÔÚÒþ²ØÓòÖÐÓÉformÌá½»¡£
ÊÊÓÃÊý¾Ý£º´óÁ¿Êý¾Ý£¬°üÀ¨ÎļþÉÏ´«¡£
ÊÊÓ÷¶Î§£ºÍ¬Get·½·¨
Ó÷¨£ºÔÚ¿Í»§¶ËformÖ¸¶¨actionÄ¿±êºósubmit¡¢ÔÚasp.netµÄËÅ·þ¶ËÖÐʹÓÃserver.Transfer(url)Ìá½»£»ÔÚËÅ·þ¶ËÖÐÓÃRequest.Form["FormFieldID"]»ñÈ¡¡£
3. Ò³Ãæ¶ÔÏóµÄÊôÐÔ
·½Ê½£ºasp.netÌØÓз½Ê½ ¡£ÀûÓÃHttpContext»ñÈ¡·¢ÇëÇóµÄÒ³ÃæµÄÐÅÏ¢¡£
ÌØµã£º¿ÉÒÔÖ±½Ó´æ´¢¶ÔÏó¡£
ȱµã£º×¢ÒâÇ¿ÖÆ×ª»»µÄÀàÐÍÒªÕýÈ·¡£
ÊÊÓÃÊý¾Ý£º¸÷ÖÖÊý¾Ý¡£
ÊÊÓ÷¶Î§£ºÒ³ÃæÖ®¼ä´«µÝ¸´ÔÓÊý¾Ý¡£
Ó÷¨£º»ñÈ¡Context.Handler½«Æäת»»Îª·¢ÇëÇóµÄÒ³ÃæµÄʵÀý£¬Ëæºó¾Í¿ÉÒÔÇáËÉ·ÃÎÊÆäformÖеÄ×ֶΡ¢ÉõÖÁÊôÐÔ¡£ÆäÖеÄContextÊÇÖ¸HttpContext¶ÔÏó£¬HandlerÊÇÆäÊôÐÔ£¬Context.HandlerµÄÒâ˼¿ÉÒÔÀí½âΪ´´½¨Ô´Ò³ÀàµÄʵÀý±äÁ¿£¬¶øµÃµ½´ËʵÀýÖ®ºó£¬¾Í¿ÉÒÔÖ±½Ó·ÃÎÊÆäÖеÄÊôÐÔºÍPublic·½·¨ÁË¡£
4. cookie
·½Ê½£º½«Êý¾Ý´æÔÚ¿Í»§¶ËµÄ¾µä·½·¨¡£
ȱµã£º°²È«ÐԵ͡¢Êܿͻ§¶ËÉèÖÃÏÞÖÆ¡¢Ò»¸öÕ¾µã½ö´æ20¸öcookie£¬Ã¿¸öÈÝÁ¿4096×Ö½Ú¡£
ÓÐЧÆÚ£º×Ô¶¨Òå»ò±»Óû§Çå³ý
ÊÊÓÃÊý¾Ý£ºÓû§µÄ»á»°Êý¾Ý(Ò»°ãÊÇÓû§Ãû£¬Óû§µÄ¸öÐÔ»¯ÉèÖÃÐÅÏ¢µÈ)
ÊÊÓ÷¶Î§£ºµ¥¸öÓû§¡¢Õû¸öÕ¾µãËùÓÐÒ³Ãæ
Ó÷¨£ºÒýÓÃRequest
Ïà¹ØÎĵµ£º
MVC2 ¿ò¼Ü°²×°Íê³ÉÒÔºóÎÒÃǾͿÉÒÔ¿ªÊ¼ÎÒÃÇµÄ MVCÖ®ÂÃÁË£¬ºÇºÇ
±¾´ÎѧϰÄÚÈÝ£ºRoute
Ê×ÏÈ route µÄÖÐÎÄÒâ˼¾ÍÊÇÎÒÃdz£ËµµÄ“·ÓÉ”£¬È·ÊµÕâÀïÒ²ÊÇÕâ¸öÒâ˼£¬ÔÚÎÒÃÇMVCÖÐÒѾ²»ÔÙʹÓà XX.aspx À´·ÃÎÊÒ³ÃæÁË£¬
ËùÓÐÒ³ÃæµÄÇëÇó»áͨ¹ýrouteÀ´½âÎöÕÒµ½¶ÔÓ¦µÄ¿ØÖÆÆ÷(controller)ÀïÃæ¶ÔÓ¦µÄ²Ù×÷(action)À´Ö´Ðеġ£
mv ......
ÉÏ´ÎÎÒÃÇ˵µ½ÁË route ·ÓɵŦÄÜ,Õû¸ömvcÔËÐйý³Ì:
Route(·ÓÉ) --> Controller(¿ØÖÆÆ÷)-->action(·½·¨)
Õâ´ÎÎÒÃÇҪ˵µÄ¾ÍÊÇ controller ¿ØÖÆÆ÷ ºÍ action£º
¿ØÖÆÆ÷µÄ×÷ÓþÍÊÇ£ºµ±Ò»¸ö Request À´µÄʱºò£¬Ê×ÏÈRoute ½âÎö ÕÒµ½ÁË ¶ÔÓ¦ ¿ØÖÆÆ÷£¬¿ØÖÆÆ÷ÔÙ¸ù¾Ý action ¾ö¶¨¸øÎÒÃÇ·µ»ØÊ²Ã´ÑùµÄÄÚÈÝ¡£È磺
´úÂë ......
Ê×ÏȽ¨Á¢¿Ø¼þGridView1£¬×¢ÒâàÞ
Ò³ÃæEnableEventValidation="false"±ØÐëµÄ¡£
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="P ......
Ò³Ãæµ¼³öExcelʱ£¬³£ÓõÄÖ±½ÓRenderControlµÄ·½·¨£¬Èç¹û±í¸ñÖÐÓÐÊý×Ö£¬ÔÚExcelÖÐÍùÍù¸ñʽ»áÂÒ£¬±ÈÈçÇ°ÃæÓÐ0£¬µ«ÏÔʾ³öÀ´ºó0¶¼±»È¥µôÁË¡£
Òò´ËÒªÔÚ°ó¶¨Êý×ÖµÄʱºò£¬ÊÖ¶¯Ö¸¶¨Ò»Ï´ËÁеĸñʽ£¬ÈÃÊý×ÖÒÔÎı¾·½Ê½ÏÔʾ¾ÍÐÐÁË
protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
......
[תÌùÒ»]
ʹÓÃASP.NET MVC¿ò¼Ü£¬´´½¨Ä¬ÈÏÏîÄ¿£¬µÚÒ»Ö±¹Û¸Ð¾õ¾ÍÊǵØÖ·¶¼ÊÇRewrite¹ýµÄ¡£¶ÔÔ´ÂëºÍÅäÖÃÎļþÉÔ¼Ó·ÖÎö²»ÄÑ¿´³ö£¬MVCʹÓÃÁËhttpModulesÀ´À¹½ØµØÖ·ÇëÇ󣬾ßÌåÓõ½ÁËSystem.Web.RoutingÀà¿â£¨MVC2ÖУ¬MVC1ÔõôÓõÄÍü¼ÇÁË¡££©¶øÕⲿ·ÖÀà¿â±»°ü×°ÔÚ.NET Framework3.5 SP1ÖУ¬MVC2ÐèÒªSP1Ö§³ÖÒ²¾ÍÀíËùµ±È»ÁË¡£SP1Ìṩµ ......