2
votes

I have followed all steps on this link including web.config changes and adding required assemblies.
ASP.Net and Webforms in Harmony I have installed MVC3 into the webforms project and Implemented a controller and registered its routes in Application_Start method of Global.asax.

 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

Here is the controller

 public class HomeController : Controller
{
    //
    // GET: /Default1/

    public ActionResult Index(int? id)
    {
        ViewData["Message"] = "Hello from Home controller";
        return View();
    }

}

I am trying to call its action (i.e /Home/Index) but getting 404 Not Found error.

Route registered for other .aspx form are working fine.

 routes.Add("Home", new Route("Home", new RoutingHandler("/Default.aspx")));

Everything is working fine but (Home/Index) is not showing up.

1

1 Answers

1
votes

You can accomplish this by adding Area in your web project for example MVC. Then you need to register that Area in Global class in Global.asax.cs file's function protected void Application_Start(object sender, EventArgs e) function like below

MVCAreaRegistration.RegisterAllAreas(RouteTable.Routes);

Now add a controller for example Home and add a view say Index. Place a break point on Index action method and run your application. In url type ".../MVC/Home/Index" and the break point will got hit.