ÈÏʶASP.NETÅäÖÃÎļþWeb.config
×÷ÕߣºSabine¡¡À´Ô´£ºÈüµÏÂÛ̳
¡¡¡¡Ò»¡¢ÈÏʶWeb.configÎļþ
Web.configÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ýVB.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈϵÄ
Web.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖã¬ËùÓеÄ×ÓĿ¼¶¼¼Ì³ÐËüµÄÅäÖÃÉèÖá£Èç¹ûÄãÏëÐÞ¸Ä×ÓĿ¼µÄÅäÖÃÉèÖã¬Äã¿ÉÒÔÔÚ¸Ã×ÓĿ¼ÏÂн¨Ò»¸öWeb.configÎļþ¡£Ëü¿ÉÒÔÌṩ³ý´Ó¸¸Ä¿Â¼¼Ì³ÐµÄÅäÖÃÐÅÏ¢ÒÔÍâµÄÅäÖÃÐÅÏ¢£¬Ò²¿ÉÒÔÖØÐ´»òÐ޸ĸ¸Ä¿Â¼Öж¨ÒåµÄÉèÖá£
ÔÚÔËÐÐʱ¶ÔWeb.configÎļþµÄÐ޸IJ»ÐèÒªÖØÆô·þÎñ¾Í¿ÉÒÔÉúЧ£¨×¢£º£¼processModel£¾ ½ÚÀýÍ⣩¡£µ±È»Web.configÎļþÊÇ¿ÉÒÔÀ©Õ¹µÄ¡£Äã¿ÉÒÔ×Ô¶¨ÒåÐÂÅäÖòÎÊý²¢±àдÅäÖýڴ¦Àí³ÌÐòÒÔ¶ÔËüÃǽøÐд¦Àí¡£
¶þ¡¢web.configÅäÖÃÎļþ£¨Ä¬ÈϵÄÅäÖÃÉèÖã©ÒÔÏÂËùÓеĴúÂë¶¼Ó¦¸ÃλÓÚ
£¼configuration£¾
£¼system.web£¾
¡¡¡¡ºÍ
£¼/system.web£¾
£¼/configuration£¾
Ö®¼ä£¬³öÓÚѧϰµÄÄ¿µÄÏÂÃæµÄʾÀý¶¼Ê¡ÂÔÁËÕâ¶ÎXML±ê¼Ç
1¡¢£¼authentication£¾ ½Ú
×÷ÓãºÅäÖà ASP.NET Éí·ÝÑéÖ¤Ö§³Ö£ ......
ÏÈ¿´¿´ASP.NETÒ³ÃæË¢ÐµÄʵÏÖ·½·¨£º
µÚÒ»£º
C# code
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
µÚ¶þ£º
C# code
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( " < script language=javascript>window.location.href=document.URL; < /script>" );
}
µÚÈý£º
C# code
private void Button3_Click( object sender, System.EventArgs e )
{
Response.AddHeader( "Refresh","0" );
}
µÚËÄ£º
C# code
private void Button6_Click( object sender, System.EventArgs e )
{
//ºÃÏñÓÐЩ²»¶Ô£¿
//Response.Write( " < script language=javascript>window.location.reload( ); < /script>" ); }
µÚÎ壺
HTML code
< script>< !-- var limit="3:00" if ( document.images ) { var parselimit=limit.split( ":" )parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh( ) { if ( !document.images )returnif ( parselimit==1 )window.location.reload( )else { pa ......
using System;
using System.Data;
using System.Diagnostics;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
namespace System
{
/// <summary>
/// Description of MySqlDBUtil.
/// </summary>
public class MySqlDBUtil
{
private static String connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString.ToString();
private MySqlDBUtil()
{
}
//Ö´Ðе¥Ìõ²åÈëÓï¾ä£¬²¢·µ»Øid£¬²»ÐèÒª·µ»ØidµÄÓÃExceuteNonQueryÖ´ÐС£
public static int ExecuteInsert(string sql,MySqlParameter[] parameters)
{
//Debug.WriteLine(sql);
using (MySqlConnection connection = new MySqlConnection(connectionString))
......
using System;
using System.Data;
using System.Diagnostics;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
namespace System
{
/// <summary>
/// Description of MySqlDBUtil.
/// </summary>
public class MySqlDBUtil
{
private static String connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString.ToString();
private MySqlDBUtil()
{
}
//Ö´Ðе¥Ìõ²åÈëÓï¾ä£¬²¢·µ»Øid£¬²»ÐèÒª·µ»ØidµÄÓÃExceuteNonQueryÖ´ÐС£
public static int ExecuteInsert(string sql,MySqlParameter[] parameters)
{
//Debug.WriteLine(sql);
using (MySqlConnection connection = new MySqlConnection(connectionString))
......
Asp.net¿Ø¼þ£¨°üÀ¨Web·þÎñÆ÷¿Ø¼þºÍHtml·þÎñÆ÷¿Ø¼þ£©¶¼Ã»ÓÐË«»÷ʼþ£¬ÄÇô¸ÃÈçºÎ½«Ë«»÷ʼþ¸¶¸øAsp.Net¿Ø¼þÄØ£¿ÎÒÃÇÒÔLable¿Ø¼þΪÀý¡£
Ò»¡¢Ê×ÏȼÓÈë¿Ø¼þ£¬IDΪLable1£¬È»ºó¼ÓÈëÒ»¸öButton¿Ø¼þ£¬IDΪButton1£¬´úÂëÈçÏÂ
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" />
¶þ¡¢ÔÚaspxÒ³Ãæ¼ÓÈëjavascriptº¯ÊýÏìÓ¦TextBox1Ë«»÷ʼþ£º
<script type="text/javascript">
functio ......
дcookie
¡¡¡¡1 HttpCookie cookie = new HttpCookie("Info");//¶¨Òåcookie¶ÔÏóÒÔ¼°ÃûΪInfoµÄÏî
¡¡¡¡2 DateTime dt = DateTime.Now;//¶¨Òåʱ¼ä¶ÔÏó
¡¡¡¡3 TimeSpan ts=new TimeSpan(1,0,0,0);//cookieÓÐЧ×÷ÓÃʱ¼ä£¬¾ßÌå²émsdn
¡¡¡¡4 cookie.Expires = dt.Add(ts);//Ìí¼Ó×÷ÓÃʱ¼ä
¡¡¡¡5 cookie.Values.Add("user","cxbkkk");//Ôö¼ÓÊôÐÔ
¡¡¡¡6 cookie.Values.Add("userid","1203");
¡¡¡¡7 Response.AppendCookie(cookie);//È·¶¨Ð´ÈëcookieÖÐ
¡¡¡¡¶ÁÈ¡cookie
¡¡¡¡1 if(Request.Cookies["Info"]!=null)
¡¡¡¡2 {
¡¡¡¡3 string temp=Convert.ToString(Request.Cookies["Info"].Values["user"])+" "+Convert.ToString(Request.Cookies["Info"].Values["userid"]);
¡¡¡¡4 //¶ÁÈ«²¿¾ÍÓÃRequest.Cookies["Info"].Value)
¡¡¡¡5 if(temp=="")
¡¡¡¡6 {
¡¡¡¡7 Response.Write("¿Õ");
¡¡¡¡8 }
¡¡¡¡9 else
¡¡¡¡10 ......
дcookie
¡¡¡¡1 HttpCookie cookie = new HttpCookie("Info");//¶¨Òåcookie¶ÔÏóÒÔ¼°ÃûΪInfoµÄÏî
¡¡¡¡2 DateTime dt = DateTime.Now;//¶¨Òåʱ¼ä¶ÔÏó
¡¡¡¡3 TimeSpan ts=new TimeSpan(1,0,0,0);//cookieÓÐЧ×÷ÓÃʱ¼ä£¬¾ßÌå²émsdn
¡¡¡¡4 cookie.Expires = dt.Add(ts);//Ìí¼Ó×÷ÓÃʱ¼ä
¡¡¡¡5 cookie.Values.Add("user","cxbkkk");//Ôö¼ÓÊôÐÔ
¡¡¡¡6 cookie.Values.Add("userid","1203");
¡¡¡¡7 Response.AppendCookie(cookie);//È·¶¨Ð´ÈëcookieÖÐ
¡¡¡¡¶ÁÈ¡cookie
¡¡¡¡1 if(Request.Cookies["Info"]!=null)
¡¡¡¡2 {
¡¡¡¡3 string temp=Convert.ToString(Request.Cookies["Info"].Values["user"])+" "+Convert.ToString(Request.Cookies["Info"].Values["userid"]);
¡¡¡¡4 //¶ÁÈ«²¿¾ÍÓÃRequest.Cookies["Info"].Value)
¡¡¡¡5 if(temp=="")
¡¡¡¡6 {
¡¡¡¡7 Response.Write("¿Õ");
¡¡¡¡8 }
¡¡¡¡9 else
¡¡¡¡10 ......
Parameter Queries in ASP.NET with MS Access
A selection of code samples for executing queries against MS Access using parameters.
Making use of the ASP.NET 2.0 datasource controls is fine, but it is important to understand how to manually create data access code. Best practice dictates that, at the very least, parameters are used to represent values that are passed into the SQL to be executed, rather than un-sanitised values straight from the user. The main reason for this cannot be over-emphasised in terms of its importance - it protects the application against SQL Injection attacks. In addition, parameters do not require delimiters. Therefore there is no need to worry about octothorpes (#) or apostrophes for dates, or doubling single quotes in strings.
These samples all assume that the values being passed into the parameters have been properly validated for datatype, existence, range etc, according to the business rules for the application. The serverside validation code is not i ......