0

I am having an issue with a controller not being found after I publish my project and run the api application with my front end application in Electron.

I can access the controller with visual studio debugger no issues there.

Don't know why this is happening I can access all the other controllers in the application just fine except this new one I added.

this is the controller code

[HttpGet]
[Route("Backup")]
public IEnumerable<string> Get()
{
  return new string[] { "value1", "value2" };
}

So when I debug the web api I can access the controller. I then publish the api start it through electron with this

let coreProcess = null;
function startApi() {
    const proc = require('child_process').spawn;
    // run server
    console.log(process.env.NODE_ENV === 'dev');
    console.log(`isDevelopment ${isDevelopment}`);
    console.warn(`dirname: ${__dirname}`);
    const apiPath = path.join(isDevelopment ? __dirname + '../../..' : '..', 'Home-Inventory-Application', 'core', 'Home-Inventory-Core.exe');
    console.warn(`api path: ${apiPath}`);

    coreProcess = proc(apiPath);

    coreProcess.stdout.on('data',
        (data) => {
            writeLog(`stdout: ${data}`);
            if (win == null) {
                createWindow();
            }
        });

    //Kill process when electron exits
    process.on("exit", function () {
            writeLog('exit');
            coreProcess.kill();
        });

    function writeLog(msg) {
        console.log(msg);
    }
}


and the api works with the existing controllers but the new one gets 404 Not Found

If anyone can give some suggestions on how to resolve this would be great..

I have tried running the RouteDebugger nuget package in my app but it did not work.

DRW
  • 335
  • 1
  • 3
  • 17
  • I have a question about "`new controller`", does this new controller already exist before you publish it? In addition, are you publishing through IIS? – Chen Sep 14 '22 at 01:48
  • new controller as I created it yesterday afternoon. so yes it exists . like i said above when I start kestrel to for debugging/testing i go to the route http://localhost:5000/odata/Backups/Backup and it prints the value 1 value 2, but then I publish it. run it with my front end and test the endpoint with the same url i get 404 not found .. its really weird never had this issue before . – DRW Sep 14 '22 at 02:14
  • there is proxy config file in your frontend there you need to allow any new path. just check if it has something to do with that. – CodingMytra Sep 14 '22 at 06:31
  • @CodingMytra thanks for the suggestion I do have the proxy setup and it is working cause I get the data from the database . but the call to the new controller is still not working, how would I add a new path to the proxy to allow the new controller ? It should just pick it up like it does with all the rest of them. Not sure what to do at this point. – DRW Sep 14 '22 at 17:37

1 Answers1

0

I have resolved the issue . Seems that my publish directory was wrong it was going to an old directory. I corrected the path and tested and everything works now. Thank you for those of you who replied with suggestions.

DRW
  • 335
  • 1
  • 3
  • 17