用于访问路径“/Image/Uploaded/Panorama.jpg”的 HTTP 动词 POST不允许

发布于 2024-12-13 12:11:14 字数 715 浏览 4 评论 0原文

我有一个链接按钮:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

月下伊人醉 2024-12-20 12:11:14

您正在尝试对图像资源 - jpg 执行 POST 请求。这是无效的;没有针对 jpg 资源的 POST 请求的处理程序。

也许您正在寻找的是直接链接到图像 URL,而不是使用 LinkBut​​tonPostBackUrl

You are trying to do a POST request to an image resource - jpg. That's not valid; there's no handler for POST requests for jpg resources.

Perhaps what you are looking for is to link right to the image URL, instead of using the PostBackUrl of a LinkButton

笑咖 2024-12-20 12:11:14

在标头中,您需要允许 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")

自由如风 2024-12-20 12:11:14

在我看来,您正在尝试使用 < code>ImageButton 控件而不是 LinkBut​​ton 控件,您可能正在寻找 ImageUrl 而不是 PostBackUrlImageUrl 最终在 html img 元素上呈现为 srcPostBackUrl 是单击图像按钮时用于回发的 URL。

Looks to me that you are trying to use the ImageButton control as opposed to the LinkButton control and you are probably looking for ImageUrl instead of PostBackUrl. ImageUrl ends up being rendered as src on the html img element. PostBackUrl is the URL that will be used to post back when the image button is clicked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文