不允许用于访问路径的HTTP动词POST [英] The HTTP verb POST used to access path is not allowed

查看:897
本文介绍了不允许用于访问路径的HTTP动词POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不使用URL重写,我的应用程序正常工作,直到我试着通过我已动态生成到一个LinkBut​​ton的一项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)
{
        LinkBut​​ton的LinkToDoc =(LinkBut​​ton的)e.Item.FindControl(LinkToDoc);
        标签FileNameLabel =(标签)e.Item.FindControl(FileNameLabel);
        LinkToDoc.PostBackUrl =〜/ EventDocs /+ SessionValue.EventId.ToString()+/+ FileNameLabel.Text;
        LinkToDoc.Text = FileNameLabel.Text;
}
 

解决方案

不要使用一个LinkBut​​ton。使用超链接控制。

的超级链接控件,您可以使用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:\projects\Events\EventDocs\48ea946f-e948-e011-ad73-00155d0e670b\2011.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.

这篇关于不允许用于访问路径的HTTP动词POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆