ASP.NET ·þÎñÆ÷¿Ø¼þÉúÃüÖÜÆÚ
ÔÎÄ£ºÁõÎä
| ASP.NET ·þÎñÆ÷¿Ø¼þÉúÃüÖÜÆÚ
âÒ¶¡½âÅ£:×ÝÏòÇÐÈëASP.NET 3.5¿Ø¼þºÍ×é¼þ¿ª·¢¼¼Êõ
µÚÒ»Õ½²ÁËһЩ·þÎñÆ÷¿Ø¼þµÄ»ù±¾ÖªÊ¶£¬
ÆäÖÐasp.net·þÎñÆ÷¿Ø¼þµÄÉúÃüÖÜÆÚ£¬ÊÇ¿ª·¢¿Ø¼þµÄµÚÒ»²½£¬Ò²ÊǺËÐÄ¡£
·þÎñÆ÷¿Ø¼þÉúÃüÖÜÆÚ°üÀ¨ÒÔÏÂ11¸ö½×¶Î£º
³õʼ»¯£¨OnInit)£ºÍê³É¿Ø¼þµÄ³õʼ»¯¼°´ò¿ª¿Ø¼þµÄÊÓͼ״̬¸ú×Ù¹¦ÄÜ¡£
¼ÓÔØÊÓͼ״̬£¨LoadViewState)£º±¾½×¶ÎÖ»ÔÚÒ³Ãæ»Ø·¢Ê±²ÅÖ´ÐУ¬Íê³É¼ÓÔØÊÓͼ״̬µ½¿Ø¼þµÄÈÎÎñ¡£
¼ÓÔػش«Êý¾Ý£¨LoadPostData£©£º±¾½×¶ÎÖ»ÔÚÒ³Ãæ»Ø·¢Ê±Ö´ÐУ¬ÓÃÓÚ×°ÔÚ¿Í»§¶ËÌá½»µÄÊý¾Ý
×°ÔØ£¨OnLoad£©£ºÒ³Ãæ×°ÔØʱÏÈÖ´ÐÐÒ³ÃæµÄPage_Loadʼþ£¬ÔÙÖ´Ðи÷¸ö×ӿؼþµÄOnLoad·½·¨¡£
Êý¾Ý»Ø´«Ê¼þ֪ͨ£¨RaisePostDataChangedEvent£©£º±¾½×¶ÎÖ»ÔÚÒ³Ãæ»Ø·¢Ê±Ö´ÐС£µ±LoadPostData·½·¨·µ»ØֵΪtrueʱ£¬¸Ã·½·¨²Å»á±»µ÷Óá£
´¥·¢»Ø·¢Ê¼þ£¨RaisePostBackEvent£©£º±¾½×¶Î½öÔÚÒ³Ãæ»Ø·¢Ê±Ö´ÐУ¬Ö÷Òª´¦ÀíÒýÆð»Ø·¢µÄ¿Í»§¶Ëʼþ¡£
Ô¤³ÊÏÖ£¨OnPreRender£©£º±¾½×¶ÎÖ÷ÒªÍê³É¿Ø¼þ³ÊÏÖ֮ǰËùÐèÒªµÄһЩ¹¤×÷£¬Ò»°ã¶Ô¿Ø¼þ½øÐÐ×ÊÔ´×¢²á£¬Èç×¢²ájavascript½Å±¾ºÍÒþ²ØÓò¿Ø¼þµÈ¡£
±£´æÊÓͼ״̬£¨SaveViewState£©£º°ÑÒ³Ãæ¿Ø¼þÊÓͼÐÅÏ¢½øÐд洢¡£
³ÊÏÖ£¨Render£©£ºÖ÷Òª½«¿Ø¼þ±ê¼ÇºÍ×Ö·ûÎı¾Êä³öµ½·þÎñÆ÷¿Ø¼þÊä³öÁ÷ÖУ¬¿ÉÒÔÖ±½ÓЩHTML±ê¼Ç£¬Ò²¿ÉÒÔµ÷ÓÃÿ¸ö¿Ø¼þ¶¼ÓëµÄRenderControl·½·¨¡£
жÔØ£¨OnUnload£©£º¶Ô¿Ø¼þ½øÐÐ×ÊÔ´Çå³ý¹¤×÷¡£
ÊÍ·Å£¨Dispose£©£ºÊÍ·ÅʹÓõÄ×ÊÔ´£¬ÈçÊý¾Ý¿âÁ¬½Ó£¬IOÎļþÁ÷µÈ.
ÕâÀïÖ»Êǽ²ÁËһЩ»ù±¾µÄ¸ÅÄҲÐíºÜ¶àÈË»á¾õµÃÊÇÎíÀï¿´»¨£¬Æäʵû¹Øϵ£¬¾Íµ±ÊÇÒ»¸öÒý×Ó°É£¬ÏàÐŽӴ¥µ½Êµ¼ÊµÄ¿Ø¼þ¿ª·¢Ö®ºó»á¶Ô¸÷¸öʼþÓбȽÏÉî¿ÌµÄÀí½â¡£
Ïà¹ØÎĵµ£º
Ê×Ò³£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕÊ ......
Ò»¡¢ÈÏʶWeb.configÎļþ
Web.config ÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ý.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈϵÄWeb.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖã ......
³ÌÐò´úÂë
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request = HttpContext.Current.Request;
if (request.ServerVariables["HTTP_VIA"] != null)
{
ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}
else
{
ip = requ ......
csÎļþ£º
using System.IO;
string context = "";
string path = HttpContext.Current.Server.MapPath("") + "\\test\\test.html";
System.Text.Encoding code = System.Text.Encoding.GetEncoding("utf-8");
Stre ......