Why are ASP.Net MVC2 area controller actions callable without including the area in the url path?
Posted
by Nathan Ridley
on Stack Overflow
See other posts from Stack Overflow
or by Nathan Ridley
Published on 2010-04-18T17:38:35Z
Indexed on
2010/04/18
17:43 UTC
Read the original article
Hit count: 703
I've just installed Visual Studio 2010 and have created a new MVC2 project so that I can learn about the changes and updates and have discovered an issue with areas that I'm not sure what to make of.
- I created a new EMPTY MVC2 project
- I right clicked the project and, from the context menu, added a new area called "Test"
- In the new test area, I added a controller called "Data".
The code is:
public class DataController : Controller
{
//
// GET: /Test/Data/
public ActionResult Index()
{
Response.Write("Hi");
return new EmptyResult();
}
}
Now, I compile and call this address: http://localhost/mytest/test/data and get the output:
Hi
All good. Now I call this: http://localhost/mytest/data and get the same response! I thought routing was supposed to take care of this? Am I overlooking something? Or has the default project setup for MVC2 overlooked something?
© Stack Overflow or respective owner