0

I have a solution having two MVC Web Projects.

In main project, AdminController is works as expected(When I hit Admin/Action it looks for view in main project and work accordingly).

In second project I have SiteController. When I hit Site/Action it looks for view in main project and as it is not available in main project and throw error.

I want to access second project controller through main project but don't know how to achieve this.

I do not want to use Area functionality in main project. SiteController should be in second project and should be accessible through main project.

  • Did you start both the projects. if yes both have different ports.so hit the appropriate port. – Avinash Reddy Feb 24 '21 at 06:21
  • Thank you @AvinashReddy for your response. I have started both the project and I can access Site controller through second project port but I want to access SiteController using main project port. I am accessing AdminController through 'http://localhost:port1/Admin/action' so I want to access SiteController through main project port that is port1 'http://localhost:port1/Site/action'. I can easily access SiteController though port2 but url should be 'http://localhost:port1/Site/action'. Hope I am able to clear my question. – Jayesh Suthar Feb 24 '21 at 06:40
  • Does this answer your question? [Create Route for a specific URL without changing the URL with MVC](https://stackoverflow.com/questions/48542759/create-route-for-a-specific-url-without-changing-the-url-with-mvc) – Avinash Reddy Feb 24 '21 at 07:00

1 Answers1

0

You have multiple solutions for this:

  1. Include the controllers of project 2 in project 1. This is not the same as an area but you'll have to add a reference to project 2 in project 1. asp-net-mvc-6-discovers-controllers
  2. If 1 is not an option, then you can debug directly on your local IIS without ports BUT on different site names. This makes sense as the ARE different sites. If they aren't then they should be hosted on the same project (see 1st solution).
  • Go to project properties
  • Select Web
  • On the Servers section choose local iis
  • Set the project url

enter image description here

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61