I've completed testing my ASP.NET Core app locally, and it works fine. However I'm getting 404 errors for a trigger on my view after publishing to our UAT server and I cannot determine why. I'm possibly missing something obvious and would appreciate fresh eyes. Thank you.
I have tried amending the routing in StartUp and attempted mixed routing in my controller.
Relevant part of Configure method in startup.cs:
app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=StartPage}/{id?}"); }); Relevant form in my StartPage view:
<form action="@Url.Action("StartSlsProcess", "Home")" method="post" enctype="multipart/form-data" id="trigger"> <div id="process-trigger"> @(Html.DevExtreme().Button() .Text("Start SLS") .Type(ButtonType.Success) .UseSubmitBehavior(true) ) </div> </form> Method in HomeController:
[HttpPost] public ActionResult StartSlsProcess() { var empty = new string[0]; ConsoleApp.Program.StartProcessFromUI(empty); return new EmptyResult(); } I would expect when the button is pushed on the view that it triggers the StartProcessFromUI method on my console app, continues the separate process and refreshes the view, as it does locally.
Edit: what is further confusing the issue is that my other Action works fine, and is set up the same:
<form action="@Url.Action("Upload", "Home")" method="post" enctype="multipart/form-data" id="uploader"> <div id="fileuploader-container"> @(Html.DevExtreme().FileUploader().Name("file") .ID("file-uploader") .Accept("*") .UploadMode(FileUploadMode.Instantly) .UploadUrl(Url.Action("Upload", "Home")) //.OnUploadError("fileUploader_onUploadError") //.OnValueChanged("fileUploader_valueChanged") ) </div> </form> HomeController method:
[HttpPost] public ActionResult Upload() { try { var file = Request.Form.Files["file"]; var path = Path.Combine(_hostingEnvironment.WebRootPath, "uploads"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); using(var fileStream = System.IO.File.Create(Path.Combine(path, file.FileName))) { file.CopyTo(fileStream); fileStream.Flush(); } MoveFileFromServer(path, file); } catch (Exception e) { Console.WriteLine(e); throw; } return new EmptyResult(); } Additionally, the method on my ConsoleApp, StartProcessFromUI actually gets hit, it's just that the 404 Error is then returned in the foreground.
