0

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

8
  • 1
    The simplest approach is to set up a separate site for that ASP.NET MVC application, and then use ARR with a few rules to bridge the URLs, learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/… Commented Dec 8, 2019 at 16:24
  • 1
    I suspect inheritance of configuration, i don't know with drupal how will you handle it to your sub app. But with .net we just clear the config setting we don't want to inherit. Commented Dec 9, 2019 at 2:02
  • @LexLi thank you very much. Currently I can not modify the structure to make ARR the main website "example.com" or install new things on it but your suggestion will defiantly help me in future projects. Commented Dec 9, 2019 at 6:34
  • @jomsk1e Thank you. Correct but would you please provide me a link or a source to what you do in this scenario. I will try it in case it works for drupal as well. Commented Dec 9, 2019 at 6:35
  • 1
    Did you enable the url rewrite in the web.config file? If you have enabled the url rewrite rule, please post the url rewrite rule. I guess this may cause your MVC application not work. Commented Dec 9, 2019 at 7:00

1 Answer 1

1

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

Add New WebSite

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your answer. I have done this already. Like I mentioned in the post. It gives 404 whenever I try to access it with controler/action routes. it only works for example.com/subfolder not for example.com/subfolder/Home/index

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.