The requested method POST is not allowed for the URL /index.htm

OK, I am having a problem with a post method linking to another site.  When I try to do the following line of code and link it to another site, I get the following error:

The requested method POST is not allowed for the URL /index.htm

Here is the line of code that I have on my sight that I get the problem with:

<asp:ImageButton ID="ImageButton1" ImageUrl="~/images/rsamurai.jpg" style="margin-left:20px;" PostBackUrl="http://www.rmag.com" runat="server" />

Of course the PostBackURL link has been adjusted for privacy reasons, but what other solution is there for me to add a link to a website imagebutton without running into problems?  Thanks!
VBBRettAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
tillgeffkenConnect With a Mentor Commented:
This makes it a bit reusable:


<script type="text/javascript">
function redirectTo(url)
{
   window.location.href  = url;
   return false;
}
</script>
 
<asp:ImageButton ID="ImageButton1" ImageUrl="~/images/rsamurai.jpg" style="margin-left:20px;" OnClientClick="redirectTo('http://www.rmag.com'); return false;" />

Open in new window

0
 
tillgeffkenCommented:
Is it your goal to post your form to the other site or just redirect? The error message is coming from the other site, right?
0
 
VBBRettAuthor Commented:
Yes, it is my goal to redirect or open the main page of the other site.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ajollyCommented:
use

OnClientClick="window.location='http://www.rmag.com'; return false;"
0
 
VBBRettAuthor Commented:
That didn't work out too well.  All it did was just shift the page and make me stay on that same page.
0
 
VBBRettAuthor Commented:
This should be a simple task, how do I do this without all the problems?
0
 
GuitarRichConnect With a Mentor Commented:
This is really simple - just use an anchor tag with an image, no need to over complicate things with postbacks or js imo.
<a href="http://www.rmag.com" style="margin-left:20px;"><asp:Image ImageUrl="~/images/rsamurai.jpg" id="image1" Runat="Server"></asp:Image></a>

Open in new window

0
 
tillgeffkenCommented:
Although that approach will make functionality inaccessible from code behind. Yeah, i know that the image button was missing a runat="server" property =)
0
 
VBBRettAuthor Commented:
Thank you very much gentlemen!
0
All Courses

From novice to tech pro — start learning today.