我不使用URL重写,我的应用程序正常工作,直到我试着通过我已动态生成到一个LinkButton的一项PostBackUrl链接打.PDF文件,甚至一个.TXT文件。路径是正确的。
我已经彻底地在这里研究这个问题,大多数问题都与使用POST操作与否或URL重写,而我不是人。
在IIS错误是这样的:
在应用程序服务器错误默认Web站点/事件Internet信息服务7.5
错误摘要
HTTP错误405.0 - 不允许的方法
因为无效的方法(HTTP动词)正在使用您正在查找的页面无法显示。详细的错误信息
模块StaticFileModule
通知ExecuteRequestHandler
处理器StaticFile
错误code 0x80070001
请求的URL的http://本地主机:80 /活动/ EventDocs / 48ea946f-e948-E011-ad73-00155d0e670b / 2011.pdf
物理路径C:项目活动 EventDocs 48ea946f-e948-E011-ad73-00155d0e670b 2011.pdf
code动态生成链接直接点击这里:
公共无效DocumentsRepeater_ItemDataBound(对象发件人,RepeaterItemEventArgs E)
{
LinkButton的LinkToDoc =(LinkButton的)e.Item.FindControl(LinkToDoc);
标签FileNameLabel =(标签)e.Item.FindControl(FileNameLabel);
LinkToDoc.PostBackUrl =〜/ EventDocs /+ SessionValue.EventId.ToString()+/+ FileNameLabel.Text;
LinkToDoc.Text = FileNameLabel.Text;
}
![5G安全的全球统一认证体系和标准演进](https://p.xsw88.cn/allimgs/daicuo/20230903/1547.png)
解决方案
不要使用一个LinkButton。使用超链接控制。
的超级链接控件,您可以使用NavigateUrl属性。
I am not using URL Rewriting, my app works fine until I try to hit a .PDF file or even a .TXT file via a link that I have dynamically generated into the PostBackUrl of a LinkButton. The path is correct.
I have thoroughly researched this issue on here and most of the issues are with people using a POST action or not or the URL Rewriting, which I am not.
In IIS Error looks like:
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:projectsEventsEventDocs48ea946f-e948-e011-ad73-00155d0e670b2011.pdf
Code to dynamically generate the url to click to is here:
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;
}
解决方案
Don't use a LinkButton. Use a HyperLink control.
The HyperLink control has a NavigateUrl property that you can use.
相关推荐
最新文章