I have a website which is functioning in asp.net webform application. Currently we are planning to convert this webform application to MVC with the following conditions.
- New modules alone will be developed in MVC pattern.
- Existing modules will remain in aspx page. ( no conversion to MVC).
- Home page will be (default.aspx)
for example www.example.com will point to www.example.com/default.aspx
new module which will be developed will have the following parameters.
www.example.com/place/Japan
www.example.com/place/USA
www.example.com/place/(anycountry)
so I developed a controller named place.
code:
public class PlaceController : Controller
{
//
// GET: /Place/
[HttpGet]
public ActionResult Index()
{
return View();
}
public ActionResult Index(string country)
{
return View();
}
when I type in the following URL : http://example.com/ It goes to http://example.com/default.aspx
my routeconfig has:
routes.MapRoute("Default", "{controller}/{action}/{id}", new { id = UrlParameter.Optional });
but when i add the following
routes.MapRoute(
name: "PlaceController",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Place", action = "Index", id = UrlParameter.Optional }
);
and type in www.example.com it goes to place controller, instead of going to default.aspx page. How will I solve this problem
also if I type in www.example.com/place/japan I get resource not found. How should I be modifying the index actionresult?