The HTTP verb POST used to access path is not allowed

前端 未结 3 1624
青春惊慌失措
青春惊慌失措 2020-12-22 03:34

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 Lin

相关标签:
3条回答
  • 2020-12-22 03:47

    When you use the PostBackUrl property of a LinkButton there is a POST verb being used. Quote from the documentation:

    The PostBackUrl property allows you to perform a cross-page post using the LinkButton control. Set the PostBackUrl property to the URL of the Web page to post to when the LinkButton control is clicked. For example, specifying Page2.aspx causes the page that contains the LinkButton control to post to Page2.aspx. If you do not specify a value for the PostBackUrl property, the page posts back to itself.

    So I would recommend you using a normal hyperlink:

    <a href="<%= ResolveUrl("~/files/foo.pdf") %>">foo.pdf</a>
    
    0 讨论(0)
  • 2020-12-22 03:51

    Don't use a LinkButton. Use a HyperLink control.

    The HyperLink control has a NavigateUrl property that you can use.

    0 讨论(0)
  • 2020-12-22 03:55

    There's some other property on a link button you want to set. Not PostBackUrl, because, as the name suggests, it Posts!

    0 讨论(0)
提交回复
热议问题