【发布时间】:2011-07-11 10:03:36
【问题描述】:
我没有使用 URL 重写,我的应用程序运行良好,直到我尝试通过动态生成到 LinkButton 的 PostBackUrl 中的链接点击 .PDF 文件甚至 .TXT 文件。路径是正确的。
我在这里彻底研究了这个问题,大多数问题都与人们是否使用 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;
}
【问题讨论】:
-
您收到错误消息了吗?也许您可以发布一些代码,这会有所帮助...