18

Note: I have done hours of digging for the answer, and couldn't find one.

I have an ASP.NET MVC (2.0) application, hosted on IIS7 (integrated mode).

When GET request is made to /Toons/List - I get a redirect (302) to /Toons/List/ which is expected.

THE PROBLEM
But when I send a POST request, say to /Toons/Add (notice no trailing slash) server returns, again, redirect (302) to /Toons/Add/. At this point, FireFox, mistakenly sends GET request to that redirect-to URL. I.e. [GET] /Toons/Add/ instead of [POST] /Toons/Add/. This is incorrect, but known behavior. Since there is no [GET] on /Toons/Add/ - I get resource not found (404).

I host my app with webhost4life and have no access to IIS7, which limits my use of URL rewriting and using modules (I'm working with them to work around this). But even than, is ISAPI the best way to go? I don't know it enough to feel good about doing it this way.

This got to be a common problem, I'm surprised I couldn't find an easy solution for this.

Is there a solution that doesn't involve using .aspx / .mvc suffix, and URL rewriting?
Out of those two, if I have to, which one should I prefer?

Any ideas / suggestions?

EDIT:
I have read http://www.hanselman.com/blog/ASPNETMVCAndTheNewIIS7RewriteModule.aspx, as I said, I'm trying to find an easier solution, a "Just Work" option.

EDIT:
I have seen solution with appending slash (/) to every URL, again, doesn't seem to be most elegant solution.

Alex Duggleby
8,0385 gold badges41 silver badges44 bronze badges
asked Jan 26, 2010 at 19:09
3
  • 1
    Can you show us the routes and their respective Action methods around this issue? Commented Jul 18, 2011 at 15:39
  • I am a bit confused as to what is causing a 302 to /Toons/List/ when requesting /Toons/List. +1 for posting the routes or whatever is causing the 302 and why it is expected. Commented Aug 4, 2011 at 21:01
  • problem went away at some point, I don't know what was causing that. Commented Aug 4, 2011 at 22:19

3 Answers 3

1

You should be using the actual URL/route when linking. If you are unable to remove the slash from the route because of a limitation of the hosting environment or 2.0 version of the MVC framework, you need to include the trailing slash in your URLs.

Relying on the server to redirect every URL will increase server processing time and page load time.

answered Aug 4, 2011 at 15:44
Sign up to request clarification or add additional context in comments.

Comments

0

Can you tell IIS to return a 307 instead of a 302?

answered Jul 23, 2011 at 22:15

Comments

0

Have you set the action method in the controller to accept post HttpVerbs? You can also try setting up a route in the Global.asax for the /Toons/Add so MVC isn't reading it as /Controller/Method/

answered Aug 4, 2011 at 14:31

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.