在起始頁錯誤時傳遞的目錄路徑
protected void Button1_Click(object sender, CommandEventArgs e)
{
string[] values = e.CommandArgument.ToString().Split(',');
string queryString =
"editpage.aspx?path="
+ values[0];
string newWin =
"window.open('" + queryString + "');";
ClientScript.RegisterStartupScript
(this.GetType(), "pop", newWin, true);
}
queryString
究竟是= "editpage.aspx?path=D:\\C#Projects\\website\\Lecturer\\giangvien\\profile.xml"
(我在調試時檢查它)
但是在目標頁面(彈出窗口)中:editpage.aspx
string path = Request.QueryString["path"];
string content = File.ReadAllText(path);
if(content!=null)
textarea.Value = content;
它有一個錯誤:Could not find file 'D:\C#Projects\website\C
嘗試調試,我收到了path
僅僅只是:"D:C"
而且在editpage.aspx
顯示的地址欄:
http://localhost:41148/website/editpage.aspx?path=D:C#ProjectswebsiteLecturergiangvienprofile.xml
幫助!爲什麼當我將它傳遞給編輯頁面時路徑發生了變化?
看看URL編碼的 –
可能重複[如何編碼包含哈希?](http://stackoverflow.com/questions/9319656/how-to-encode-a-path-that-contains-a-hash) –