0

how should my Global.asax file look, and the Controller's action, to get a URL like:

http://mysite.com/name

The name is a string - it may be anything.

I try:

Global.asax:

routes.MapRoute(
                "ViewContent",   // Route name
                "{name}",     // URL with parameters
                new { controller = "Main", action = "ViewC" }  // Parameter defaults
            );

MainController:

public ActionResult ViewC(string name)
{
    ...
}

but it doesn't "go" inside that action.

1
  • What does it do instead? 404? Commented Dec 4, 2010 at 19:05

1 Answer 1

1

try

    routes.MapRoute("Default", "{name}",
                    new {.controller = "Main",
                         .action = "ViewC",
                         .name = UrlParameter.Optional});

You might also want to make that controller return the view "name"

public ActionResult ViewC(string name)
{
    return view(name);
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.