Controller not found after publishing project in Asp.net Core

602 views Asked by At

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.

1

There are 1 answers

0
DRW On

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.