Asp.Net¹¹¼Ü(HttpÇëÇó´¦ÀíÁ÷³Ì) Part.1
URL:
http://www.cnblogs.com/JimmyZhang/archive/2007/09/04/880967.html
ÒýÑÔ
ÎÒ²éÔĹý²»ÉÙAsp.NetµÄÊé¼®£¬·¢ÏÖ´ó¶àÊý×÷Õ߶¼ÊÇÕ¾ÔÚÒ»¸ö±È½Ï¸ßµÄ²ã´ÎÉϽ²½âAsp.Net¡£ËûÃÇÄÍÐÄ¡¢Ï¸ÖµظæËßÄãÈçºÎÒ»²½²½ÍϷſؼþ¡¢ÉèÖÿؼþÊôÐÔ¡¢±àдCodeBehind´úÂ룬ÒÔʵÏÖij¸öÌض¨µÄ¹¦ÄÜ¡£
ÕâÖÖ×ö·¨£¬Êµ¼ÊÉÏÊǻشðÁË“ÈçºÎÈ¥×ö”µÄÎÊÌ⣬ȴûÓлشð“Ϊʲô¿ÉÒÔÕâÑù×ö”µÄÎÊÌâ¡£
¾¡¹ÜÎÒºÜÍƳç Ϥ½»ª ÏÈÉúµÄ¡¶Ê¥µî¼ÀìëµÄAsp.Net¿ª·¢Ïê½â¡·Ò»Ê飬µ«µ±ÎÒ·¿´ÁËÒ»ÏÂÆä¶Ô½ÇÉ«(Role) ºÍ Óû§(Member)µÄ½²½âʱ£¬ÎÒ¾ö¶¨Ìø¹ýÈ¥Ö±½Ó¶ÁºóÃæµÄÕ½ڡ£ÒòΪÎÒ·¢ÏÖËûÒ²ËæÁË´óÁ÷£¬¶ÔÕⲿ·ÖµÄ½²½âÍ£ÁôÔÚ“ÈçºÎÈ¥×ö”µÄ²ãÃæÉÏ¡£ÎÒÏàÐÅÏñϤÏÈÉú ÕâÑùµÄÅ£ÈËÊDz»¿ÉÄܲ»Á˽âµ×²ãÔË×÷ÔÀíµÄ£¬½ö½öÊÇÒòΪÄDZ¾ÊéÔ±¾¾ÍÒѾºÜºñÁË°É¡£
µ±Äã°´“ÈçºÎÈ¥×ö”Ëù½²½âµÄÄÚÈÝÈ¥¿ª·¢³ÌÐòµÄʱºò£¬¶ÔÓÚÄãµÄÓû§£¬ÄãÈÔÊÇÒ»Ãû³ÌÐòÔ±£»µ«¶ÔÓÚʵÏÖÁËMembershipProvider ºÍ RoleProvider ³éÏóÀàµÄ΢Èí¿ª·¢ÈËÔ±À´Ëµ£¬ÄãÒѾ³ÉÁËËûÃǵÄÒ»¸öÓû§¡£
NOTE£ºÎҼȲ»·´¶ÔһЩ×÷ÕßÖ»½²½â“ÈçºÎÈ¥×ö”£¬Ò²²»·´¶ÔÄãֻѧ“ÈçºÎÈ¥×ö”£¬ÕâÑùÒ²ÓÐËüµÄºÃ´¦£¬¾ÍÊÇ¿ÉÒÔ¿ìËÙ¿ª·¢¡£ÎÒÖ»Êǽ¨Òé¶àÕÆÎÕÒ»µãµ×²ã֪ʶ£¬¶ÔһЩÎÊÌâ»áÓиüºÃµÄÀí½â¡£
Ï£Íûͨ¹ýÕâһϵÁÐÎÄÕµĽ²½â£¬¿ÉÒÔÈÃÄã¸üºÃµÄÀí½âAsp.NetµÄÔË×÷ÔÀíºÍ×öÒÔÁ˽⡣
HttpÇëÇó´¦ÀíÁ÷³Ì¸ÅÊö
˼¿¼“ΪʲôÔÚµØÖ·À¸ÊäÈëwww.tracefact.net¾Í¿ÉÒÔ¿´µ½ÕÅ×ÓÑôµÄ¸öÈ˿ռ䣿”£¬ÀàËÆÓÚ˼¿¼“Ϊʲôƻ¹ûÊÇÍùµØÉϵô²»ÊÇÍùÌìÉÏÆ®£¿”¡£¶ÔÓÚÆÕͨ·ÃÎÊÕßÀ´Ëµ£¬Õâ¾ÍÏñÿÌìÌ«Ñô¶«±ßÉýÆðÎ÷±ßÂäÏÂÒ»ÑùÊÇÀíËùµ±È»µÄ£»¶ÔÓںܶà³ÌÐòÔ±À´Ëµ£¬ÈÏΪÕâ¸öÓ뼺Î޹أ¬²»¹ýÊÇϵͳ¹ÜÀíÔ±»òÕßÍø¹ÜÔ±µÄÔðÈΡ£±Ï¾¹£¬IISÊÇ Windows µÄÒ»¸ö×é¼þ£¬ÓÖ²»ÊÇ Asp.Net µÄÒ»¸ö×é³É²¿·Ö¡£¶øʵ¼ÊÉÏ£¬´ÓÄãÇáÅĻسµµ½Ò³Ãæ³ÊÏÖÔÚÄãÑÛÇ°µÄÊ®·ÖÖ®Ò»ÃëÄÚ£¬IISºÍ.Net FrameworkÒѾ×öÁË´óÁ¿µÄÄ»ºó¹¤×÷¡£
Äã¿ÉÄܾõµÃÁ˽âÕâЩĻºó¹¤×÷ÊÇÈçºÎÔË×÷µÄÎ޹ؽôÒª£¬×÷Ϊ³ÌÐòÔ±µÄÄãÖ»Òª±£Ö¤¿ª·¢³öµÄ³ÌÐò¿ÉÒÔ¸ßЧµØÔËÐоͿÉÒÔÁË¡£È»¶ø£¬ÔÚ¿ª·¢¹ý³ÌÖУ¬ÄãÈ´·¢ÏÖ³£³£ÐèҪʹÓÃÖîÈç HttpContext ÕâÑùµÄÀà¡£Õâ¸öʱºò£¬Äã¿ÉÔø˼¿¼¹ýÕâЩÀàµÄ¹¹³ÉºÍÀàµÄʵÌåÊÇÈçºÎ´´½¨µÄ£¿Äã¿ÉÄܼòµ¥µØ»Ø´ð£ºHttpContext´ú±íµ±Ç°ÇëÇóµÄÒ»¸öÉÏÏÂÎÄ»·¾³¡£¿ÉÄãÓÖÖªµÀIIS ¡¢Framework¡¢Asp.Net ÊÇÈçºÎÐͬ¹¤×÷´¦Àíÿ¸öHttpÇëÇó¡¢ÈçºÎÇø·Ö²»Í¬µÄÇëÇó¡¢IIS¡¢Framework¡¢Asp.Ne
Ïà¹ØÎĵµ£º
WebÀï¼ÓÈë<sessionState cookieless="false" mode="StateServer" timeout="60" stateNetworkTimeout="3600" sqlCommandTimeout="3600"/>ºó±ØÐ루cmdÀïÔËÐÐ:Net Start aspnet_state£©²Å¿ÉÒÔÉèÖÃsessionÖµ¡£
ÕâÒ»¶Î¾ÍÊÇÅäÖÃÓ¦ÓóÌÐòÊÇÈçºÎ´æ´¢SessionÐÅÏ¢µÄÁË¡£ÎÒÃÇÒÔϵĸ÷ÖÖ²Ù×÷Ö÷ÒªÊÇÕë¶ÔÕâÒ»¶ÎÅäÖÃÕ¹ ......
SQL½Å±¾£º
CREATE TABLE tblBooksUpload
(
¡¡DocID int NOT NULL IDENTITY Primary Key ,
¡¡DocTitle varchar (200) ,
¡¡Doc image,
¡¡DocType varchar (50) ,
¡¡Entrydate datetime Default GetDate()
)
Ê×ÏÈÎÒÃÇҪʵÏÖÓû§ÔÚä¯ÀÀÆ÷¶Ë×ÔÓÉÑ¡ÔñÎļþ£¬È»ºóÉÏ´«£¬ÕâÀïÓû§Ñ¡ÔñÎļþ£¬µ±È»ÊÇÒªÇó±ê×¼µÄWindows·½Ê½£ ......
public bool SaveExcel(GridView paramGridView)
{
if (paramGridView.Rows.Count == 0)
{
return false;
}
//´´½¨Excel¶ÔÏó
Microsoft.Office.Interop.Excel.Application myExcel = new Microsoft.Office.Interop.Excel.Appl ......
µÚÒ»²½£ºÀýÈçÓû§¿Ø¼þ·ÅÔÚMyList.Ascx£¬È»ºóÆäControlÖ¸ÁîÊÇ£º
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ViewComment.ascx.cs" Inherits="Control_ViewComment"%>
ÕâʱºòÒѾÓÐÁËInherits£¬×Ô´øÁËClassName¾ÍÊÇÆäÃû³Æ£¬Èç¹ûûÓУ¬Ôò±ØÐë´´½¨ClassNameÊôÐÔ¡£
¼ÙÉèÆäÓй«¹²ÊôÐÔID¡£
µÚ¶þ²½£ ......
Asp.netÁ¬½ÓSQL Server2000Êý¾Ý¿âÀý³ÌÏê½â:
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
<script laguage="VB" runat="server">
sub page_load(sender as Object ......