Call from one MVC5 project method to another MVC5 project method not loading aspx page

iqworks Information Quality Works 276 Reputation points
2024-06-14T03:01:54.9366667+00:00

  Hi, I have two projects, MVC5-1 and MVC5-2. Both are using .net 4.7.. I have installed MVC5 on both.

 I am trying to call a controller method from MVC5-2 (ShowMBStest())from MVC5-1.

There is a method in MVC5-2 that calls an x.aspx page. I can see it gets into the MVC5-2 method with debug, but when it runs the code it does not display the x.aspx page. This is the MVC5-2 method ( DisplayLoggingMaint() ) and code. 

This is the method in MVC5-1 that calls MVC5-2.

   public EmptyResult ShowMBStest() //MVC5-1

   {                  

        MBSAnalysisMVCWebApp.MBSAnalysisMainController iwebapp =

        new MBSAnalysisMVCWebApp.MBSAnalysisMainController();

        iwebapp.DisplayLoggingMaint("In a it");

          

         return new EmptyResult();

   }

public ActionResult DisplayLoggingMaint(string eData). //MVC5-2

 {

   //MbsTest.aspx is in the MVC5-2 root directory.
```        return Redirect("~/MbsTest.aspx");         

 } 

Instead it goes through this MVC5-2 DisplayLoggingMaint method, and then, continues through the MVC5-1 (ShowMBStest()) calling method, and it displays the ShowMBStest.cshtml. 

Thanks for any advice or suggestions 

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,405 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. QiYou-MSFT 4,311 Reputation points Microsoft Vendor
    2024-06-14T08:30:37.2066667+00:00

    Hi @iqworks Information Quality Works

    First of all, an aspx page requires a lot of basic files to run. Such as Site.Master and Global.asax. You just move the file over and you won't get it running.

    So my suggestion:

    You create a webform project and generate an aspx file and run the project.

    Next, change the redirected address in the controller to the URL of your webform project file.

    Such as:

    public ActionResult DisplayLoggingMaint(string eData). 
    {          
    return Redirect("https://localhost:44304/MbsTest");
     } 
    

    Best regards,

    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. AgaveJoe 27,581 Reputation points
    2024-07-17T17:33:15.2166667+00:00

    As far as I can tell you created a project reference between two projects MVC1 and MVC2. In my opinion, this is not a good design. If you want to share code between MVC application either create a class library or a Web API project.

    0 comments No comments