用于访问路径“/Image/Uploaded/Panorama.jpg”的 HTTP 动词 POST不允许
我有一个链接按钮:
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" Text="View" PostBackUrl='<%# Eval("Name", "../Image/Uploaded/{0}") %>'>
Eval 值基于加载到表单视图的图像。
例如,我想查看 Panorama.jpg 图像,当我单击该链接按钮时,错误显示:
The HTTP verb POST used to access path '/Image/Uploaded/Panorama.jpg' is not allowed.
我已尝试使用此代码来解决,但结果是相同的:
Dim imgUplPath As String = Request.PhysicalApplicationPath & "../Image/Uploaded/"
Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, imgUplPath)
Try
f2.Demand()
Catch s As SecurityException
Console.WriteLine(s.Message)
End Try
任何人都可以帮助我吗?多谢
I've a link button:
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" Text="View" PostBackUrl='<%# Eval("Name", "../Image/Uploaded/{0}") %>'>
The Eval value is based on what image is loaded to the formview.
For example, I want to view the Panorama.jpg image and while I am clicking that linkbutton, the error shows:
The HTTP verb POST used to access path '/Image/Uploaded/Panorama.jpg' is not allowed.
I've tried using this code to solved but it is the same:
Dim imgUplPath As String = Request.PhysicalApplicationPath & "../Image/Uploaded/"
Dim f2 As New FileIOPermission(FileIOPermissionAccess.Read, imgUplPath)
Try
f2.Demand()
Catch s As SecurityException
Console.WriteLine(s.Message)
End Try
Anyone can help me, please? Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在尝试对图像资源 -
jpg
执行POST
请求。这是无效的;没有针对jpg
资源的POST
请求的处理程序。也许您正在寻找的是直接链接到图像 URL,而不是使用
LinkButton
的PostBackUrl
You are trying to do a
POST
request to an image resource -jpg
. That's not valid; there's no handler forPOST
requests forjpg
resources.Perhaps what you are looking for is to link right to the image URL, instead of using the
PostBackUrl
of aLinkButton
在标头中,您需要允许 POST
Response.AddHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS")
In your header , you will need to allow POST
Response.AddHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS")
在我看来,您正在尝试使用 < code>ImageButton 控件而不是
LinkButton
控件,您可能正在寻找ImageUrl
而不是PostBackUrl
。ImageUrl
最终在 htmlimg
元素上呈现为src
。PostBackUrl
是单击图像按钮时用于回发的 URL。Looks to me that you are trying to use the
ImageButton
control as opposed to theLinkButton
control and you are probably looking forImageUrl
instead ofPostBackUrl
.ImageUrl
ends up being rendered assrc
on the htmlimg
element.PostBackUrl
is the URL that will be used to post back when the image button is clicked.