Andam
Andam

Reputation: 2167

IIS Host Asp.Net MVC application in sub-folder

Im trying to host my c# asp.net MVC application under a sub-folder of a drupal website in IIS.

What Im really trying to achieve is the following example When I access this path www.example.com the drupal website should open and when I access www.example.com/subfolder the MVC application should open

So I have create an application inside the drupal website as in the picture below

enter image description here

The result is when I access www.example.com/subfolder the default controller and default action is called and the default view for the MVC application shows. That being said, it does not work for other views. Whenever I try to access www.example.com/subfolder/Home/SecondAction it just shows a 404 error. Even if I try access the default view via www.example.com/subfolder/Home/Index does not work and shows 404

I have tried route prefix and route attributes for controller and I have tried these route bindings none of them works

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

        //routes.MapRoute(
        //    "SubFolder", // Route name
        //    "EDF/{controller}/{action}",
        //    new { controller = "Home", action = "Index" },
        //    new[] { "EDF.EDF.Controllers" }
        //);

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


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

I know some of them does not even make sense but I was desperate at this point and tried everything.

Any idea, suggestion and solution are very appreciated

Upvotes: 0

Views: 1740

Answers (1)

Mohammad
Mohammad

Reputation: 971

Do not need to change your application routes. Add a new website and change physical path to your published files location.

Add New WebSite

Upvotes: 1

Related Questions