我沒有使用URL重寫,我的應用程序工作正常,直到我試圖通過我已動態生成的鏈接打到.PDF文件甚至是.TXT文件爲止LinkButton的PostBackUrl。路徑是正確的。用於訪問路徑的HTTP動詞POST是不允許的
我已經徹底研究了這裏這個問題,大多數問題與使用人POST操作或不或URL重寫,這我不是。
在IIS錯誤的樣子:
Server Error in Application "DEFAULT WEB SITE/EVENTS"Internet Information Services 7.5
Error Summary
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. Detailed Error Information
Module StaticFileModule
Notification ExecuteRequestHandler
Handler StaticFile
Error Code 0x80070001
Requested URL http://localhost:80/Events/EventDocs/48ea946f-e948-e011-ad73-00155d0e670b/2011.pdf
Physical Path C:\projects\Events\EventDocs\48ea946f-e948-e011-ad73-00155d0e670b\2011.pdf
代碼動態生成的URL點擊這裏:
public void DocumentsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
LinkButton LinkToDoc = (LinkButton)e.Item.FindControl("LinkToDoc");
Label FileNameLabel = (Label)e.Item.FindControl("FileNameLabel");
LinkToDoc.PostBackUrl = "~/EventDocs/" + SessionValue.EventId.ToString() + "/" + FileNameLabel.Text;
LinkToDoc.Text = FileNameLabel.Text;
}
你得到一個錯誤信息?也許你可以發佈一些代碼,這將有所幫助... –