ASP.NET ÈçºÎÈ¡µÃ Request URL µÄ¸÷個²¿·Ö?
ÎÒ們ÔÚ開發網頁應ÓóÌʽ£¬時³£ÐèҪȥ½âÎö網Ö·(Request.Url)µÄÿ個Ƭ¶Î£¬進ÐÐһЩÅÐ斷¡£ÀýÈç說 "http://localhost:1897/News/Press/Content.aspx/123?id=1#toc
"£¬ÎÒ們ÏëҪȡµÃ網Ö·裡µÚÒ»層Ä¿錄µÄÃû×Ö(News)ÓÃÒÔÅÐ斷²»Í¬µÄ頁Ãæ標題(Page Title)¡£
ÎÒ¿´ºÜ¶àÈ˶¼ÓÃ×Ö´®µÄ IndexOf ·½·¨與 Substring ·½·¨£º
Request.Url.PathAndQuery.Substring(1, Request.Url.PathAndQuery.IndexOf("/", 1)-1)
這實ÔÚÌ«Âñ沒 .NET µÄ強´ó設計ÁË£¬ÊÂ實ÉÏÔÚ Request Îï¼þ¾ÍÒÑ經ÌṩºÜ¶à·½±ãµÄ屬ÐÔ(Property)¿É¹©È¡µÃ網Ö·µÄƬ¶Î¡£
µ×ÏÂ這張±í¾ÍÊǸ÷種¸ú Browser Request µÄ網Ö·Ïà關µÄ屬ÐÔ與Ó÷¨£º
網Ö·£ºhttp://localhost:1897/News/Press/Content.aspx/123?id=1#toc
Request.ApplicationPath
/
Request.PhysicalPath
D:\Projects\Solution\web\News\Press\Content.aspx
System.IO.Path.GetDirectoryName(Request.PhysicalPath)
D:\Projects\Solution\web\News\Press
Request.PhysicalApplicationPath
D:\Projects\Solution\web\
System.IO.Path.GetFileName(Request.PhysicalPath)
Content.aspx
Request.CurrentExecutionFilePath
/News/Press/Content.aspx
Request.FilePath
/News/Press/Content.aspx
Request.Path
/News/Press/Content.aspx/123
Request.RawUrl
/News/Press/Content.aspx/123?id=1
Request.Url.AbsolutePath
/News/Press/Content.aspx/123
Request.Url.AbsoluteUri
http://localhost:1897/News/Press/Content.aspx/123?id=1
Request.Url.Scheme
http
Request.Url.Host
localhost
Request.Url.Port
1897
Request.Url.Authority
localhost:1897
Request.Url.LocalPath
/News/Press/Content.aspx/123
Request.PathInfo
/123
Request.Url.PathAndQuery
/News/Press/Content.aspx/123?id=1
Request.Url.Query
?id=1
Request.Url.Fragment
Request.Url.Segments
/
News/
Press/
Content.aspx/
123
ËùÒÔ當Äã¿´ÁË這張±íÖ®áᣬÄã還會ÏëÓà Request.Url.PathAn
Ïà¹ØÎĵµ£º
Ò»£¬JS¶¯Ì¬´´½¨±íµ¥
var result = " <form method='post' action='../xiazai.aspx'><table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#BDB4A2'>"+
"&l ......
using System.Web;
/// <summary>
/// Javascript³£Ó÷½·¨
/// </summary>
public class JS
{
private static string ScriptStart = "<script type=\"text/javascript\">";
private static string ScriptEnd = "</script>";
&n ......
1. C#ÓïÑÔ·½Ãæ
1.1 À¬»ø»ØÊÕ
¡¡À¬»ø»ØÊÕ½â·ÅÁËÊÖ¹¤¹ÜÀí¶ÔÏóµÄ¹¤×÷£¬Ìá¸ßÁ˳ÌÐòµÄ½¡×³ÐÔ£¬µ«¸±×÷ÓþÍÊdzÌÐò´úÂë¿ÉÄܶÔÓÚ¶ÔÏó´´½¨±äµÃËæÒâ¡£
¡¡1.1.1 ±ÜÃâ²»±ØÒªµÄ¶ÔÏó´´½¨
¡¡ÓÉÓÚÀ¬»ø»ØÊյĴú¼Û½Ï¸ß£¬ËùÒÔC#³ÌÐò¿ª·¢Òª×ñѵÄÒ»¸ö»ù±¾ÔÔò¾ÍÊDZÜÃâ²»±ØÒªµÄ¶ÔÏó´´½¨¡£ÒÔÏÂÁоÙһЩ³£¼ûµÄÇéÐΡ£
¡¡1.1.1.1 ±ÜÃâÑ»·´´½¨¶ÔÏ ......
protected
void Page_Load(object sender, EventArgs e)
{
try
{
//query the pdf path
& ......