Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure网站-502-Web服务器在充当网关或代理服务器时收到无效响应_C#_Azure_Azure Web App Service - Fatal编程技术网

C# Azure网站-502-Web服务器在充当网关或代理服务器时收到无效响应

C# Azure网站-502-Web服务器在充当网关或代理服务器时收到无效响应,c#,azure,azure-web-app-service,C#,Azure,Azure Web App Service,我的web应用在本地计算机上运行正常,但发布到Windows Azure网站时,我在其中一个控制器操作方法上出现以下错误: 502-Web服务器在充当网关或代理服务器时收到无效响应。 您正在查找的页面有问题,无法显示。当Web服务器(充当网关或代理时)联系上游内容服务器时,它收到来自内容服务器的无效响应 我使用Elmah获取更多信息,我得到: System.ArgumentNullException 值不能为null。参数名称:path2 因此,当我在方法中使用path.combine(path

我的web应用在本地计算机上运行正常,但发布到Windows Azure网站时,我在其中一个控制器操作方法上出现以下错误:

502-Web服务器在充当网关或代理服务器时收到无效响应。 您正在查找的页面有问题,无法显示。当Web服务器(充当网关或代理时)联系上游内容服务器时,它收到来自内容服务器的无效响应

我使用Elmah获取更多信息,我得到: System.ArgumentNullException 值不能为null。参数名称:path2

因此,当我在方法中使用path.combine(path1,path2)时,它是引用的。当我检查输出目录时,我不知道发生了什么,输入文件被很好地读取,输出文件被很好地生成

关于可能发生的事情还有其他建议吗

以下是我的操作方法的代码:

        [HttpPost]
        public ActionResult ProcessProducts(UploadViewModel model)
        {
            DateTime startTime = DateTime.UtcNow;
            DateTime endTime;
            TimeSpan totalTime;            
            PulProcessor prodManager = new PulProcessor();
            string filePath = Path.Combine(Server.MapPath("~/files/incoming"), model.ProductsFileName);

            try
            {                
                using (TextReader prodFile = System.IO.File.OpenText(filePath))
                {
                    CsvReader csv = new CsvReader(prodFile);
                    // map is at end of this file
                    csv.Configuration.RegisterClassMap<PulMap>();
                    List<PulProduct> prodList = csv.GetRecords<PulProduct>().ToList();

                    foreach (var product in prodList)
                    {
                        prodManager.ProcessProduct(product);
                    }
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }
            string currentDate = DateTime.UtcNow.ToString("yyyyMMdd");
            string productFileName = "PUL" + currentDate + ".txt";
            string exceptionsFileName = "PUL" + currentDate + "belowcost.txt";

            WriteFile(prodManager.Products, productFileName);
            WriteFile(prodManager.BelowCost, exceptionsFileName);

            endTime = DateTime.UtcNow;
            totalTime = endTime - startTime;

            ViewBag.StartTime = startTime.ToString();
            ViewBag.EndTime = endTime.ToString();
            ViewBag.TotalTime = totalTime.ToString();
            ViewBag.TotalOutput = prodManager.Products.Count.ToString();
            ViewBag.ProductCounter = prodManager.RecordsProcessed;
            ViewBag.FileName = productFileName;
            ViewBag.ExFileName = exceptionsFileName;
            ViewBag.Exceptions = prodManager.BelowCost.Count.ToString();

            return View();
        }

    private void WriteFile(List<PulFinalProduct> prodList, string fileName)
    {
        try
        {
            string filePath = Path.Combine(Server.MapPath("~/files/pul"), fileName);
            StreamWriter writer = new StreamWriter(filePath, false);
            StringBuilder fileHeader = new StringBuilder();

            fileHeader.Append("Inventory Number\t");
            fileHeader.Append("MPN\t");
            fileHeader.Append("Retail Price\t");
            fileHeader.Append("Seller Cost\t");
            fileHeader.Append("Buy It Now Price\t");
            fileHeader.Append("Starting Bid\t");
            fileHeader.Append("ChannelAdvisor Store Price\t");
            fileHeader.Append("Quantity\t");
            fileHeader.Append("Quantity Update Type\t");
            fileHeader.Append("UPC\t");
            fileHeader.Append("Weight\t");
            fileHeader.Append("Brand\t");
            fileHeader.Append("Manufacturer\t");

            using (writer)
            {
                writer.WriteLine(fileHeader.ToString());

                foreach (var product in prodList)
                {
                    StringBuilder productLine = new StringBuilder();
                    productLine.Append(product.InventoryNumber + "\t");
                    productLine.Append(product.MPN + "\t");
                    productLine.Append(product.RetailPrice.ToString() + "\t");
                    productLine.Append(product.SellerCost.ToString() + "\t");
                    productLine.Append(product.BINPrice.ToString() + "\t");
                    productLine.Append(product.StartingBid.ToString() + "\t");
                    productLine.Append(product.CAStorePrice + "\t");
                    productLine.Append(product.Quantity + "\t");
                    productLine.Append(product.QUType + "\t");
                    productLine.Append(product.UPC + "\t");
                    productLine.Append(product.Weight + "\t");
                    productLine.Append(product.Brand + "\t");
                    productLine.Append(product.Manufacturer + "\t");

                    writer.WriteLine(productLine.ToString());
                }
            }
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
        }
    }
[HttpPost]
public ActionResult ProcessProducts(UploadViewModel模型)
{
DateTime startTime=DateTime.UtcNow;
日期时间结束时间;
时间跨度总时间;
纸浆处理器prodManager=新纸浆处理器();
字符串filePath=Path.Combine(Server.MapPath(“~/files/incoming”)、model.ProductsFileName);
尝试
{                
使用(text阅读器prodFile=System.IO.File.OpenText(文件路径))
{
CsvReader csv=新CsvReader(prodFile);
//地图在这个文件的末尾
csv.Configuration.RegisterClassMap();
List prodList=csv.GetRecords().ToList();
foreach(产品列表中的var产品)
{
prodManager.ProcessProduct(产品);
}
}
}
捕获(例外情况除外)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
}
字符串currentDate=DateTime.UtcNow.ToString(“yyyyMMdd”);
字符串productFileName=“PUL”+currentDate+“.txt”;
字符串例外filename=“PUL”+currentDate+“belowcost.txt”;
WriteFile(prodManager.Products、productFileName);
WriteFile(prodManager.BelowCost,exceptionsFileName);
endTime=DateTime.UtcNow;
totalTime=结束时间-开始时间;
ViewBag.StartTime=StartTime.ToString();
ViewBag.EndTime=EndTime.ToString();
ViewBag.TotalTime=TotalTime.ToString();
ViewBag.TotalOutput=prodManager.Products.Count.ToString();
ViewBag.ProductCounter=prodManager.RecordsProcessed;
ViewBag.FileName=产品文件名;
ViewBag.ExFileName=例外文件名;
ViewBag.Exceptions=prodManager.BelowCost.Count.ToString();
返回视图();
}
私有void WriteFile(列表prodList,字符串文件名)
{
尝试
{
字符串filePath=Path.Combine(Server.MapPath(“~/files/pul”),文件名);
StreamWriter writer=新StreamWriter(文件路径,false);
StringBuilder文件头=新的StringBuilder();
fileHeader.Append(“库存编号\t”);
fileHeader.Append(“MPN\t”);
fileHeader.Append(“零售价\t”);
fileHeader.Append(“卖方成本”);
追加(“立即购买价格”);
fileHeader.Append(“起始出价\t”);
追加(“ChannelAdvisor存储价格\t”);
fileHeader.Append(“数量\t”);
fileHeader.Append(“数量更新类型\t”);
追加(“UPC\t”);
fileHeader.Append(“Weight\t”);
fileHeader.Append(“Brand\t”);
fileHeader.Append(“制造商\t”);
使用(编写器)
{
writer.WriteLine(fileHeader.ToString());
foreach(产品列表中的var产品)
{
StringBuilder productLine=新的StringBuilder();
productLine.Append(product.InventoryNumber+“\t”);
productLine.Append(product.MPN+“\t”);
productLine.Append(product.RetailPrice.ToString()+“\t”);
productLine.Append(product.SellerCost.ToString()+“\t”);
productLine.Append(product.BINPrice.ToString()+“\t”);
productLine.Append(product.StartingBid.ToString()+“\t”);
productLine.Append(product.CAStorePrice+“\t”);
productLine.Append(product.Quantity+“\t”);
productLine.Append(product.QUType+“\t”);
productLine.Append(product.UPC+“\t”);
productLine.Append(product.Weight+“\t”);
productLine.Append(product.Brand+“\t”);
productLine.Append(product.Manufacturer+“\t”);
WriteLine(productLine.ToString());
}
}
}
捕获(例外情况除外)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
}
}
以下是Azure事件日志给我的信息:

Value cannot be null. Parameter name: path2 at System.IO.Path.Combine(String path1, String path2) at Jemco.Web.Controllers.PartsUnlimitedController.ProcessProducts(UploadViewModel model) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__36(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass30.<BeginInvokeActionMethodWithFilters>b__2f(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<>c__DisplayClass28.<BeginInvokeAction>b__19() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 
值不能为空。参数名称:System.IO.Path.Combine(String path1,String path2)中的path2,Jemco.Web.controller.PartsUnlimitedController.ProcessProducts(UploadViewModel模型),lambda_方法(闭包,ControllerBase,Object[]),System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller,Object[]参数)在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,IDictionary`2参数)执行(ControllerContext ControllerContext,IDictionary`2参数