Am trying to run python script file using ASP.NET C#. Using Python.net since IronPython does not support libraries I use. Is there any Python.net resources or example projects that I may possible use?
I want to pass the id from C# to the end() and get the similar_ids back to C#. Am facing serious difficulty coding the C# part.
Not sure if the C# code is correct implementation bc this is my first python project. C# code
private string run_cmd()
{
string fileName = @"C:/Users/hongy/OneDrive/Desktop/fypV2/v1.py";
string python = @"C:/Users/hongy/AppData/Local/Programs/Python/Python311/python.exe";
Process psi = new Process();
psi.StartInfo = new ProcessStartInfo(python, fileName)
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
psi.Start();
string output = psi.StandardOutput.ReadToEnd();
return output;
}
Python code
def end(id):
similar_ids = find_similar_jobs(id, X, k=5)
for i in similar_ids:
print(p[i])