Title left blank since I can't think of non inflammatory title for this post
This works:
This doesn't:
I haven't bothered to find why, but that is surprising to me. (Note that here the enctype is specified as "multipart/form-data", which may or may not be related)
Update: It is not related.
The real culprit, as best I was able to reconstruct is because of this piece of code:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new {controller = "Home", action = "Index", id = String.Empty} ); }
It looks fairly innocuous, doesn't it?
Except that this means that when ASP.Net MVC looks for a matching value for the "id" parameter, it will only look in the route parameters, and not look at the request parameters.
I found this surprising, to say the least.
Comments
Without more details, it's hard to tell what's going on. We do look in the Request first before we look at route data to populate action method parameters so what you found is surprising to me as well.
Yeah that's caught me off guard a few times as well..
Not too sure what the reason for it is.
Maybe it's because the default "id" that comes from the route overrides the "id" that is supplied by the Request
We got around that little issue by using a "CompositeDictionary" that wraps HttpRequest and the routing dictionary.
Dude, get over it.
On a side note, the title of this post is "inflammatory":
"Title left blank since I can't think of non inflammatory title for this post"
Don't you ever make mistakes?
Why don't you just do as everyone else and post questions on the ASP.NET forum or stackoverflow?
It could be a bug , why should you start a flame (as the title implies) over a bug?
Ayende I think one of the quotes in the code is not recognized, thus the rest of the page has brown font color.
Simone,
This is a reaction to people calling my previous post title inflammatory.
Since I couldn't think of any title that couldn't be constructed as inflammatory, I used that one.
And I am not generally strong on forums, I generally have a strong dislike of them.
I am doing what I always did, putting stuff that I run into during my work on the blog.
I am not seeing that, what browser are you using?
IE 7.0
Fixed, thanks
@Phil,
Actually I've run into the same issue today and IIRC in previous releases you used to do this but recently it seems to have changed. In fact, if you have a route parameter and a POST field with the same name, then the same issue occurs. Can you confirm this to be a bug or intentional change?
Comment preview