MVC Действие контроллера / dll работает только на localhost - PullRequest
0 голосов
/ 07 августа 2020

У меня есть MVC, который принимает значения из формы, отправляет их в dll, чтобы выполнить logi c и назначить их модели. Затем модель возвращается в вид. В localhost это успешно, и я получаю следующий результат: Successful local host image

However when I publish the webapp to an azure instance, it doesn't return any of the values. You can see it here: http://levelupsite.azurewebsites.net/ или смотрите изображение здесь неудачная попытка веб-сайта

Кто-нибудь знает, чем это могло быть? Прилагаю код ниже:

Контроллер:


       [HttpPost]
       public ActionResult CBC(System.Web.Mvc.FormCollection form, FFAC model)
       {

           //recieve values from form
           var email = escapeCharactersspace((form["email"].ToString()));
           var Gender = Convert.ToString(model.UserGender);
           var UserID = escapeCharactersspace((form["username"].ToString()));
           var Neutrophils = escapeCharactersspace(form["Neutrophils"]);
           var Lymphocytes = escapeCharactersspace(form["Lympthocytes"]);
           var Monocytes = escapeCharactersspace(form["Monocytes"]);
           var Eosinophils = escapeCharactersspace(form["Eosinophils"]);
           var Basophils = escapeCharactersspace(form["Basophils"]);
           var Platelets = (escapeCharactersspace(form["Platelets"]));
           var Haematocrit = escapeCharactersspace(form["Haematocrit"]);
           var Haemoglobin = escapeCharactersspace(form["Haemoglobin"]);
           var MCV = escapeCharactersspace(form["MCV"]);
           var MCH = (escapeCharactersspace(form["MCH"]));
           var MCHC = escapeCharactersspace(form["MCHC"]);

           //turn form to array
           decimal[] cbcInputs = { Convert.ToDecimal(Neutrophils), Convert.ToDecimal(Lymphocytes), Convert.ToDecimal(Monocytes), Convert.ToDecimal(Eosinophils), Convert.ToDecimal(Basophils), Convert.ToDecimal(Platelets), Convert.ToDecimal(Haematocrit), Convert.ToDecimal(Haemoglobin), Convert.ToDecimal(MCV), Convert.ToDecimal(MCH), Convert.ToDecimal(MCHC) };

           //create instance of model
           var scfiae = new FIAECBC();

           //create instance of external class library
           var fiae = new FIAEngine();

           //send inputs & model instance to external class library to perform logic
           fiae.setcbcvals(cbcInputs, UserID, Gender, scfiae);


           //return the get results page
           return View("GetResults", scfiae);



       }

FIAEngine - dll, которая выполняет лог c

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharedComponents;
using static SharedComponents.FIAECBC;

namespace FIAE
{

   public class FIAEngine
   {
       decimal d_Neutrophils;
       decimal d_Lymphocytes;
       decimal d_Monocytes;
       decimal d_Eosinophils;
       decimal d_Basophils;
       decimal d_Platelets;
       decimal d_Haematocrit;
       decimal d_Haemoglobin;
       decimal d_MCV;
       decimal d_MCH;
       decimal d_MCHC;
       string UserID;
       string Gender;

       string Neutrophils;
       string Lymphocytes;
       string Monocytes;
       string Eosinophils;
       string Basophils;
       string Platelets;
       string Haematocrit;
       string Haemoglobin;
       string MCV;
       string MCH;
       string MCHC;

       string rag_Neutrophils;
       string rag_Lymphocytes;
       string rag_Monocytes;
       string rag_Eosinophils;
       string rag_Basophils;
       string rag_Platelets;
       string rag_Haematocrit;
       string rag_Haemoglobin;
       string rag_MCV;
       string rag_MCH;
       string rag_MCHC;


       public void Setcbcfilevals(FIAECBC cbcmodel)
       {

       }

       public void setcbcvals(decimal[] inputs, string _UserID, string _Gender, FIAECBC cbcmodel)
       {


           d_Neutrophils = inputs[0];
           d_Lymphocytes = inputs[1];
           d_Monocytes = inputs[2];
           d_Eosinophils = inputs[3];
           d_Basophils = inputs[4];
           d_Platelets = inputs[5];
           d_Haematocrit = inputs[6];
           d_Haemoglobin = inputs[7];
           d_MCV = inputs[8];
           d_MCH = inputs[9];
           d_MCHC = inputs[10];
           UserID = _UserID;
           Gender = _Gender;

           Neutrophils = "Neutrophils";
           Lymphocytes = "Lymphocytes";
           Monocytes = "Monocytes";
           Eosinophils = "Eosinophils";
           Basophils = "Basophils";
           Platelets = "Platelets";
           Haematocrit = "Haematocrit";
           Haemoglobin = "Haemoglobin";
           MCV = "MCV";
           MCH = "MCH";
           MCHC = "MCHC";

           rag_Neutrophils = "i";
           rag_Lymphocytes = "i";
           rag_Monocytes = "i";
           rag_Eosinophils = "i";
           rag_Basophils = "i";
           rag_Platelets = "i";
           rag_Haematocrit = "i";
           rag_Haemoglobin = "i";
           rag_MCV = "i";
           rag_MCH = "i";
           rag_MCHC = "i";

           try
           {

               //male calculations
               if (Gender == "Male")
               {
                   rag_Neutrophils = FindMaleRAG(d_Neutrophils, 1);
                   rag_Lymphocytes = FindMaleRAG(d_Lymphocytes, 2);
                   rag_Monocytes = FindMaleRAG(d_Monocytes, 3);
                   rag_Eosinophils = FindMaleRAG(d_Eosinophils, 4);
                   rag_Basophils = FindfeMaleRAG(d_Basophils, 5);
                   rag_Platelets = FindMaleRAG(d_Platelets, 6);
                   rag_Haematocrit = FindMaleRAG(d_Haematocrit, 7);
                   rag_Haemoglobin = FindMaleRAG(d_Haemoglobin, 8);
                   rag_MCV = FindMaleRAG(d_MCV, 9);
                   rag_MCH = FindMaleRAG(d_MCH, 10);
                   rag_MCHC = FindMaleRAG(d_MCHC, 11);

                   //set view model values to the form values

                   cbcmodel.d_Neutrophils = d_Neutrophils;
                   cbcmodel.d_Lymphocytes = d_Lymphocytes;
                   cbcmodel.d_Monocytes = d_Monocytes;
                   cbcmodel.d_Eosinophils = d_Eosinophils;
                   cbcmodel.d_Basophils = d_Basophils;
                   cbcmodel.d_Platelets = d_Platelets;
                   cbcmodel.d_Haematocrit = d_Haematocrit;
                   cbcmodel.d_Haemoglobin = d_Haemoglobin;
                   cbcmodel.d_MCV = d_MCV;
                   cbcmodel.d_MCH = d_MCH;
                   cbcmodel.d_MCHC = d_MCHC;

                   cbcmodel.Neutrophils = Neutrophils;
                   cbcmodel.Lymphocytes = Lymphocytes;
                   cbcmodel.Monocytes = Monocytes;
                   cbcmodel.Eosinophils = Eosinophils;
                   cbcmodel.Basophils = Basophils;
                   cbcmodel.Platelets = Platelets;
                   cbcmodel.Haematocrit = Haematocrit;
                   cbcmodel.Haemoglobin = Haemoglobin;
                   cbcmodel.MCV = MCV;
                   cbcmodel.MCH = MCH;
                   cbcmodel.MCHC = MCHC;

                   cbcmodel.rag_Neutrophils = rag_Neutrophils;
                   cbcmodel.rag_Lymphocytes = rag_Lymphocytes;
                   cbcmodel.rag_Monocytes = rag_Monocytes;
                   cbcmodel.rag_Eosinophils = rag_Eosinophils;
                   cbcmodel.rag_Basophils = rag_Basophils;
                   cbcmodel.rag_Platelets = rag_Platelets;
                   cbcmodel.rag_Haematocrit = rag_Haematocrit;
                   cbcmodel.rag_Haemoglobin = rag_Haematocrit;
                   cbcmodel.rag_MCV = rag_MCV;
                   cbcmodel.rag_MCH = rag_MCH;
                   cbcmodel.rag_MCHC = rag_MCHC;

                   

               }




               else if (Gender == "Female")
               {
                   rag_Neutrophils = FindfeMaleRAG(d_Neutrophils, 1);
                   rag_Lymphocytes = FindfeMaleRAG(d_Lymphocytes, 2);
                   rag_Monocytes = FindfeMaleRAG(d_Monocytes, 3);
                   rag_Eosinophils = FindfeMaleRAG(d_Eosinophils, 4);
                   rag_Basophils = FindfeMaleRAG(d_Basophils, 5);
                   rag_Platelets = FindfeMaleRAG(d_Platelets, 6);
                   rag_Haematocrit = FindfeMaleRAG(d_Haematocrit, 7);
                   rag_Haemoglobin = FindfeMaleRAG(d_Haemoglobin, 8);
                   rag_MCV = FindfeMaleRAG(d_MCV, 9);
                   rag_MCH = FindfeMaleRAG(d_MCH, 10);
                   rag_MCHC = FindfeMaleRAG(d_MCHC, 11);

                   //set view model values to the form values
                   cbcmodel.d_Neutrophils = d_Neutrophils;
                   cbcmodel.d_Lymphocytes = d_Lymphocytes;
                   cbcmodel.d_Monocytes = d_Monocytes;
                   cbcmodel.d_Eosinophils = d_Eosinophils;
                   cbcmodel.d_Basophils = d_Basophils;
                   cbcmodel.d_Platelets = d_Platelets;
                   cbcmodel.d_Haematocrit = d_Haematocrit;
                   cbcmodel.d_Haemoglobin = d_Haemoglobin;
                   cbcmodel.d_MCV = d_MCV;
                   cbcmodel.d_MCH = d_MCH;
                   cbcmodel.d_MCHC = d_MCHC;

                   cbcmodel.Neutrophils = Neutrophils;
                   cbcmodel.Lymphocytes = Lymphocytes;
                   cbcmodel.Monocytes = Monocytes;
                   cbcmodel.Eosinophils = Eosinophils;
                   cbcmodel.Basophils = Basophils;
                   cbcmodel.Platelets = Platelets;
                   cbcmodel.Haematocrit = Haematocrit;
                   cbcmodel.Haemoglobin = Haemoglobin;
                   cbcmodel.MCV = MCV;
                   cbcmodel.MCH = MCH;
                   cbcmodel.MCHC = MCHC;

                   cbcmodel.rag_Neutrophils = rag_Neutrophils;
                   cbcmodel.rag_Lymphocytes = rag_Lymphocytes;
                   cbcmodel.rag_Monocytes = rag_Monocytes;
                   cbcmodel.rag_Eosinophils = rag_Eosinophils;
                   cbcmodel.rag_Basophils = rag_Basophils;
                   cbcmodel.rag_Platelets = rag_Platelets;
                   cbcmodel.rag_Haematocrit = rag_Haematocrit;
                   cbcmodel.rag_Haemoglobin = rag_Haematocrit;
                   cbcmodel.rag_MCV = rag_MCV;
                   cbcmodel.rag_MCH = rag_MCH;
                   cbcmodel.rag_MCHC = rag_MCHC;

               }
           }
           catch (Exception ex)
           {
       
           }

       //return inputs;
   }


       public string FindMaleRAG(decimal i, int x)
       {
           String connString = Convert.ToString(ConfigurationManager.ConnectionStrings["SQLServerCon"]);

           //for each row, do this
         
               //find the threshld values
               String thresholdquery = @"select * from dbo.malethreshold where ID = " + x;
               using (var conn = new SqlConnection(connString))
               {
                   conn.Open();
                   using (SqlCommand command = new SqlCommand(thresholdquery, conn))
                   {
                       using (SqlDataReader reader = command.ExecuteReader())
                       {
                           while (reader.Read())
                           {
                               //compare threshold values t posted values from form
                               string composite = Convert.ToString(reader[1]);
                               decimal redlow = Convert.ToDecimal(reader[2]);
                               decimal greenlow = Convert.ToDecimal(reader[3]);
                               decimal greenhigh = Convert.ToDecimal(reader[4]);
                               decimal redhigh = Convert.ToDecimal(reader[5]);

                               if (i < redlow)
                               {
                                   // Red low
                                   return ("red");
                               }
                               else if (i > redlow && i < greenlow)
                               {
                                   // Amber Low
                                   return ("orange");
                               }
                               else if (i >= greenlow && i <= greenhigh)
                               {
                                   //green
                                   return ("green");
                               }
                               else if (i > greenhigh && i < redhigh)
                               {
                                   //amber high
                                   return ("orange");
                               }
                               else if (i > redhigh)
                               {
                                   // Redhigh
                                   return ("red");
                               }
                               else
                               {
                                   //sorting error
                                   return ("error in sorting");
                               }
                           }
                       }
                   }
               }
           
           return ("sorting error");
       }

       public string FindfeMaleRAG(decimal i, int x)
       {
           String connString = Convert.ToString(ConfigurationManager.ConnectionStrings["SQLServerCon"]);

           //for each row, do this

           //find the threshld values
           String thresholdquery = @"select * from dbo.malethreshold where ID = " + x;
           using (var conn = new SqlConnection(connString))
           {
               conn.Open();
               using (SqlCommand command = new SqlCommand(thresholdquery, conn))
               {
                   using (SqlDataReader reader = command.ExecuteReader())
                   {
                       while (reader.Read())
                       {
                           //compare threshold values t posted values from form
                           string composite = Convert.ToString(reader[1]);
                           decimal redlow = Convert.ToDecimal(reader[2]);
                           decimal greenlow = Convert.ToDecimal(reader[3]);
                           decimal greenhigh = Convert.ToDecimal(reader[4]);
                           decimal redhigh = Convert.ToDecimal(reader[5]);

                           if (i < redlow)
                           {
                               // Red low
                               return ("red");
                           }
                           else if (i > redlow && i < greenlow)
                           {
                               // Amber Low
                               return ("orange");
                           }
                           else if (i >= greenlow && i <= greenhigh)
                           {
                               //green
                               return ("green");
                           }
                           else if (i > greenhigh && i < redhigh)
                           {
                               //amber high
                               return ("orange");
                           }
                           else if (i > redhigh)
                           {
                               // Redhigh
                               return ("red");
                           }
                           else
                           {
                               //sorting error
                               return ("error in sorting");
                           }
                       }
                   }
               }
           }
           return ("sorting error");
       }
   }
}

FIAECB C модель

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace SharedComponents
{
   public class FIAECBC
   {
       public string Neutrophils { get; set; }
       public string Lymphocytes { get; set; }
       public string Monocytes { get; set; }
       public string Eosinophils { get; set; }
       public string Basophils { get; set; }
       public string Platelets { get; set; }
       public string Haematocrit { get; set; }
       public string Haemoglobin { get; set; }
       public string MCV { get; set; }
       public string MCH { get; set; }
       public string MCHC { get; set; }

       

       public decimal d_Neutrophils { get; set; }
       public decimal d_Lymphocytes { get; set; }
       public decimal d_Monocytes { get; set; }
       public decimal d_Eosinophils { get; set; }
       public decimal d_Basophils { get; set; }
       public decimal d_Platelets { get; set; }
       public decimal d_Haematocrit { get; set; }
       public decimal d_Haemoglobin { get; set; }
       public decimal d_MCV { get; set; }
       public decimal d_MCH { get; set; }
       public decimal d_MCHC { get; set; }

       public string rag_Neutrophils { get; set; }
       public string rag_Lymphocytes { get; set; }
       public string rag_Monocytes { get; set; }
       public string rag_Eosinophils { get; set; }
       public string rag_Basophils { get; set; }
       public string rag_Platelets { get; set; }
       public string rag_Haematocrit { get; set; }
       public string rag_Haemoglobin { get; set; }
       public string rag_MCV { get; set; }
       public string rag_MCH { get; set; }
       public string rag_MCHC { get; set; }



       public Gender UserGender { get; set; }

       public static IEnumerable<SelectListItem> GetSelectItems()
       {
           yield return new SelectListItem { Text = "Male", Value = "Male" };
           yield return new SelectListItem { Text = "Female", Value = "Female" };
       }

       public bool Bookkeeping { get; set; }

   }


   public enum Gender
   {
       Male,
       Female
   }

}

...