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

asp.net C#ÍøÕ¾ÏîÄ¿ »ñÈ¡ÎïÀí·¾¶¡¢ÐéÄâ·¾¶µÄ·½·¨

-----------------------------.csÀàÎļþÖÐ
µ±Ç°ÏîÄ¿µÄÎïÀí·¾¶Â  
   
  strPath   =   this.Server.MapPath(Request.PhysicalApplicationPath);  
   
  ÄãҪ˵Ã÷ʲô“ÀàÎļþ”¡£ÈκÎPAGE¡¢CONTROL´úÂëÒ²ÊÇÔÚÀàÖеġ£  
   
  ÉÏÃæµÄthisÖ»Õë¶ÔPage¶ÔÏó£¬Õë¶ÔcontrolÄãÓ¦¸ÃÌ滻Ϊthis.Page¡£ÄãÒ²¿ÉÒÔʹÓ㺠 
   
  strPath   =   HttpContext.Current.Server.MapPath
(HttpContext.Current.Request.PhysicalApplicationPath);  
   
  »òÕߣ¬Ê¹Ó㺠 
   
  strPath   =   AppDomain.CurrentDomain.BaseDirectory;  
--------------------------------´øpageµÄÒ³Ãæ.csÖÐ
ºÜ¾­³£Ê¹Óõ½µÄÒ»¸ö¹¦ÄÜ,µ«ÔÚÔÚÍøÉÏȴһֱûÓÐÕÒµ½Ïà¹ØµÄ½â¾ö·½·¨,½ñÌì½è×ÅÏîÄ¿Ó¦Óõ½µÄ»ú»áдÁËÁ½
¸ö½«¾ø¶Ô·¾¶×ª»»ÎªÐéÄâ·¾¶·â×°ºÃµÄ·½·¨
¡¡¡¡½«WebÕ¾µãϵľø¶Ô·¾¶×ª»»ÎªÏà¶ÔÓÚÖ¸¶¨Ò³ÃæµÄÐéÄâ·¾¶
¡¡¡¡/**//// <summary>
¡¡¡¡/// ½«WebÕ¾µãϵľø¶Ô·¾¶×ª»»ÎªÏà¶ÔÓÚÖ¸¶¨Ò³ÃæµÄÐéÄâ·¾¶
¡¡¡¡/// </summary>
¡¡¡¡/// <param name="page">µ±Ç°Ò³ÃæÖ¸Õ룬һ°ãΪthis</param>
¡¡¡¡/// <param name="specifiedPath">¾ø¶Ô·¾¶</param>
¡¡¡¡/// <returns>ÐéÄâ·¾¶, ÐÍÈç: ../../</returns>
¡¡¡¡public static string ConvertSpecifiedPathToRelativePathForPage(Page page, string
specifiedPath)
¡¡¡¡{
¡¡¡¡ // ¸ùĿ¼ÐéÄâ·¾¶
¡¡¡¡ string virtualPath = page.Request.ApplicationPath;
¡¡¡¡ // ¸ùĿ¼¾ø¶Ô·¾¶
¡¡¡¡ string pathRooted = HostingEnvironment.MapPath(virtualPath);
¡¡¡¡ // Ò³ÃæÐéÄâ·¾¶
¡¡¡¡ string pageVirtualPath = page.Request.Path;
¡¡¡¡ if (!Path.IsPathRooted(specifiedPath) || specifiedPath.IndexOf(pathRooted) == -1)
¡¡¡¡ {
¡¡¡¡ throw new Exception(string.Format("\"{0}\"ÊÇÐéÄâ·¾¶¶ø²»ÊǾø¶Ô·¾¶!", specifiedPath));
¡¡¡¡ }
¡¡¡¡ // ת»»³ÉÏà¶Ô·¾¶
¡¡¡¡ //(²âÊÔ·¢ÏÖ£¬pathRooted ÔÚ VS2005 ×Ô´øµÄ·þÎñÆ÷¸úÔÚIISϸùĿ¼»òÕßÐéÄâĿ¼ÔËÐÐËƺõ²»Ò


Ïà¹ØÎĵµ£º

asp.net »ñÈ¡ÍøÕ¾¸ùĿ¼

»ñÈ¡ÍøÕ¾¸ùĿ¼µÄ·½·¨Óм¸ÖÖÈ磺
Server.MapPath(Request.ServerVariables["PATH_INFO"])
 Server.MapPath("/")
 Server.MapPath("")
Server.MapPath(".")
 Server.MapPath("../")
 Server.MapPath("..")
  &nb ......

·µ»Ø°´Å¥µÄʵÏÖ·½·¨£¨asp.net ÖУ©


·µ»Ø°´Å¥µÄʵÏÖ·½·¨£¨asp.net ÖУ©
Òý×Ô:http://blog.sina.com.cn/s/blog_49df2d0b0100aqoy.html
·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔ­À´ÊäÈëµÄÊý¾Ý½øÐÐÐÞ¸ÄʱÓõģ¬»òÕßÊÇÒòΪÍøվΪÁË·½±ãä¯ÀÀÕ߶øÓÐÐÄÌí¼Ó µÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.netÖж¼ÊÇÓÃÒ»¸öbuttonµÄ¿ ......

Asp.net AJAX Web Serviceд·¨²îÒì

ÔÚC#ÖÐ
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
using System.Collections;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.Ba ......

ASP.NET Web.configÅäÖÃÏê½â

Ò»¡¢ÈÏʶWeb.configÎļþ
Web.config ÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ý.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈ쵀 Web.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖ㬠......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ