Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NET Òì³£´¦Àí

ASP.NET Òì³£´¦Àí
ÔÚ
Asp.net
¿ª·¢¹ý³ÌÖУ¬ÎÒÃÇ»áÓöµ½ºÜ¶à
Exception
£¬²»´¦ÀíÕâЩ
Exception
µÄ»°»á³öÏÖºÜÄÑ¿´µÄÒ³Ãæ¡£
»¹ÓÐһЩÎÒÃÇδԤÁϵ½µÄ
Exception
£¬µ±·¢Éú
Exception
ʱ£¬ÎÒÃÇÒ²±ØÐë½øÐмǼ¾ßÌåλÖã¬ÒÔ±ãÎÒÃÇÐÞÕý´íÎó¡£
asp.net
Òì³£´¦ÀíµÄλÖôó¸ÅÓÐÒÔÏÂ
3
¸öµØ·½
1.
³ÌÐòµÄ´úÂë¶ÎÖУ¬ÕâÊÇ×îÖ±½Ó´¦ÀíÒì³£µÄµØ·½¡£ÈçÏÂ
try
{
    n=Convert.ToInt32(info);
}
catch(Exception)
{
}
Ö»ÊÇ×î»ù±¾´¦ÀíÒì³£µÄµØ·½¡£
2. ASP.NET
µÄÖеÄ
Application_Error
ÖÐ
.Application_Error
ʼþ¡£¶ÔÓÚÓ¦ÓóÌÐòÖÐÒý·¢µÄÈκÎδ´¦ÀíÒì³£¶¼»áÒý·¢´Ëʼþ¡£Ò»°ãÎÒÃÇ´¦ÀíÈçÏÂ
protected void Application_Error(Object sender, EventArgs e)
  {
    Exception exp=Server.GetLastError();
    string strE="
ÄÚ²¿´íÎó
:"+ exp.InnerException.ToString()+"\r\n
¶ÑÕ»£º
"+ exp.StackTrace+"\r "+"Message:"+exp.Message+"\r
À´Ô´
:"+exp.Source;
   
   // ÔÚʼþÈÕÖ¾ÖмǼÒì³£ÐÅÏ¢
   Log(strE);
   Server.ClearError();
   Server.Transfer("Error.aspx",false);
  }
ÕâÑùÎÒÃǾͿÉÒÔ´¦Àí
Server
¶Ë³öÏֵĴíÎó¡£ÎÒÃǼǼ³ö´íµÄÔ´Í·¡£
3.
Ò²¿ÉÒÔÔÚÒ³¼¶±ð»òÕßÓ¦ÓóÌÐò¼¶±ð´¦Àí´úÂë´íÎó¡£
Page
»ùÀ๫¿ªÁËÒ»¸ö
Page_Error
·½·¨£¬´Ë·½·¨ÔÚÒ³ÖпÉÒÔ±»ÖØд¡£Ã¿µ±ÔËÐÐʱÒý·¢Î´²¶»ñµÄÒ쳣ʱ¶¼µ÷Óô˷½·¨¡£
void Page_Error(Object source, EventArgs e) {
    String message = "<font face=verdana color=red>"
        + "<h4>" + Request.Url.ToString() + "</h4>"
        + "<pre><font color='red'>"
        + Server.GetLastError().ToString() + "</pre>"
        + "</font>";
    Response.Write(message);
}
 
ÏÂÃæÎÒ½²ÊöÒ»ÏÂÔõôÔÚ
ASP.NET
³ÌÐòÀïÃæͳһµÄ´¦ÀíÒì


Ïà¹ØÎĵµ£º

ASP.NET ·þÎñÆ÷¿Ø¼þäÖȾµ½¿Í»§¶ËÖ®ºó¶ÔÓ¦µÄHTML±êÇ©

·þÎñÆ÷¿Ø¼þ        html±ê¼Ç
label----------<span/>
button---------<input type="submit"/>
textbox--------<input type="text"/>
linkbutton-----<a href="javascript:" />
imagebutton----<input type="image"/>
hyperlink------<a />
......

asp.netÓòÃû°ó¶¨¡¢É¾³ý·½·¨

#region ÓòÃû°ó¶¨·½·¨
    public static void AddHostHeader(int siteid, string ip, int port, string domain)//Ôö¼ÓÖ÷»úÍ·£¨Õ¾µã±àºÅ.ip.¶Ë¿Ú.ÓòÃû£©
    {
        DirectoryEntry site = new DirectoryEntry("IIS://localhost/W3SVC/" + siteid) ......

asp.netÖÐÈçºÎʹÓÃ΢ÈíµÄURLRewriter½øÐÐurlÖØд

asp.netÖÐÈçºÎ½øÐÐurlÖØд£¬½ñÌìÑо¿ÁËÒ»ÌìÕâ¸öÎÊÌâ
ÏëʵÏÖÖîÈ磺http://www.51cto.com/2008/2/2
http://www.51cto.com/default.html
µÈÕâÖÖurl
µ±È»£¬³ÌÐòÖ±½ÓÉú³É¾²Ì¬Ò³Ãæ¿ÉÒÔʵÏÖµÄ
µ«ÊÇÄÇÑùÒªÉú³ÉºÜ¶àÕâÖÖÒ³ÃæÒÔ¼°Îļþ¼Ð
¶øÇÒÔÚÊý¾ÝÁ¿´óµÄÇé¿öÏÂÉú³ÉÊǺÜÀË·Ñʱ¼äµÄ
ÔÚÕâÖÖÇé¿öϾÍҪʵÏÖurlÖØдÁË£¬µ±È»¾ ......

asp.net ÊÂÎñÀý×Ó

protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn;
SqlCommand cmd1, cmd2;
SqlTransaction tra;
conn = new SqlConnection("server=.;database=test;uid=sa;pwd=123");
conn.Open();
tra = conn.BeginTransaction();//¿ªÊ¼ÊÂÎ ......

URLÖØд:ʹÓÃ΢ÈíµÄURLRewrite×é¼þ½øÐÐASP.NET URL

¸ÅÊö
URLÖØдÊǽØÈ¡´«ÈëWebÇëÇó²¢×Ô¶¯½«ÇëÇóÖض¨Ïòµ½ÆäËû URL µÄ¹ý³Ì,±ÈÈçä¯ÀÀÆ÷·¢À´ÇëÇóhostname/101.aspx £¬·þÎñÆ÷×Ô¶¯½«Õâ¸öÇëÇóÖж¨ÏòΪhttp://hostname/list.aspx?id=101¡£
urlÖØдµÄÓŵãÔÚÓÚ£º
    *     Ëõ¶Ìurl£¬Òþ²Øʵ¼Ê·¾¶Ìá¸ß°²È«ÐÔ
    *    &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ