Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

As we all know MVC creates some defaults for us when we create a new MVC project:

  • Default controller is HomeController
  • Default action Index

But I've noticed that although Stackoverflow did keep the HomeController it didn't keep Index as the default action. - works - fails

I don't like the name (Index) of the default action either, that's why I'm looking for other possibilities and am wondering what's Stackoverflow's default action name?

share|improve this question
Err... I didn't know that. – innaM Oct 28 '09 at 19:27
up vote 2 down vote accepted

It can indeed Be index but if they remove the default route or replace it with the following code, then you have the same effect.

Since we know that they use this route:

    "Default", "{controller}",
    new { controller="", action="Index" }

What this route does, is that if you have what would normally be:

You'd be able to get to the index action by omitting the index. Indeed, if you took out the default route, that's the way you'd get to the index action:

To answer your question, I gather that they also have the following route:

    "Default", "",
    new { controller = "Home", action = "Index" } 
share|improve this answer
I don't think you understood my question. I was basically asking how is default route defined on Stackoverflow. Because controller is "Home" but action IS NOT "Index". – Robert Koritnik Oct 28 '09 at 18:00
@Robert Kortinik: And I'm telling you you can define the action as 'Index' and still take out the /Index path and have it work. – George Stocker Oct 28 '09 at 18:04
@George: Yes I know that. But you can see from my question that if you don't omit "Index" from the URL you get a 404. So it clearly tells me that they are using something else instead of "Index". I'm trying to find out what. – Robert Koritnik Oct 28 '09 at 18:07
@Robert: If you take out the routing or change how the routing is done for the Index action, you can indeed get it to throw an error or not be able to handle /index but still Have the action named 'index'. I don't think you understand how routing works. – George Stocker Oct 28 '09 at 18:08
@George: I do understand routing very well. It seems we don't really understand each other. I'm getting confused by your answers. Are you actually saying that Stackoverflow does have /Home/Index combination? Because it seems they don't since I'm getting 404. Unless of course if it's just POST or something similar. – Robert Koritnik Oct 28 '09 at 18:36
You can have a Home/Index but if you remove the Default route; then you wouldn't be able to get to it (and get the error you see). If you change the default route to what I wrote, then the only way to get to the Index action is to go to – George Stocker Oct 28 '09 at 18:38
@George: Yes. My fault. I missed the cleared URL that's usually set as "{controller}/{action}/{id}". You may be right, but I don't think they'd do something like that just to hide Index action... And to hide Index action onlym your call should define URL as "{controller}/", because /Home is working as expected. – Robert Koritnik Oct 28 '09 at 18:57
The beautiful thing about routing is that I can route any URL To anywhere I want. I'll update my answer to show you how they do it. – George Stocker Oct 28 '09 at 19:03
Not actually the answer I was looking for, but this is one possibility that we don't know whether it's actually done on SO or not. I was hoping someone on SO team would actually answer this one. – Robert Koritnik Oct 28 '09 at 19:13
@Robert Koritnik the great thing about MVC is that you can pretty much guess how the site is laid out from the routes that work and from the nature of MVC. I'd be very surprised if they didn't do it this way -- though I imagine they probably have regular expressions attached to the route as well. – George Stocker Oct 28 '09 at 19:14

I don't know but I hope they've filtered out the exceptions caused by invalid controller/action parameters from their ELMAH email. I imagine this question will create a flood of invalid requests as people try to guess the index action.

share|improve this answer
So better for them to share the info asap... ;) – Robert Koritnik Oct 28 '09 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .