skip to Main Content

I have an ASP.NET MVC web app running on .NET 4.6.1. I am creating a JSON file. The file is getting created locally, however when I deploy code on IIS on the server, I get an error

Invalid Signature

Even moving the existing JSON file results in the same error. I’m unable to debug as the functionality works locally.

Problem occurs only when array or list type is added to JSON file. For example – JSON file content

    "TypeOfTheTest": "Custom", 
    "ExportData": true

this works but the content shown here results in the error of "invalid signature":

    "TypeOfTheTest": "Custom", 
    "ExportData": true, 
    "DataFiles": [ "C:\Temp\1.mme" ]

I tried creating file with content

    "TypeOfTheTest": "Custom", 
    "ExportData": true 

and it works but when I add list or array type to file invalid signature occurs.

Here is detailed error from server:

Invalid Signature.

System.IO.IOException: Invalid Signature.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)  
at System.IO.FileSystemEnumerableIterator`1.CommonInit()   
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
at WebUI.Controllers.TestRequestController.CreateXCrashJasonFile(Int32 testRequestId) in C:UsersreposDEVELOPMENTWebUIControllersTestController.cs:line 0
at lambda_method(Closure , ControllerBase , Object[] )
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__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

Here is controller method

public JsonResult CreateXCrashJasonFile(int testRequestId)
    var response = new JsonResponse(message: "JSON file created successfully", success: true);

    var testRequestMacros = TestRequestMacroes.ToList();
    var macros = testRequestMacros.Select(z => z.Macro.MacroName.Trim()).ToList();

    var testPath = PictureVideoPaths;
    if (testPath != null && !string.IsNullOrEmpty(testPath.DatFolder))
        var basePath = testPath.BasePath;
        var mmeFiles = Directory.GetFiles(basePath, "*.mme", SearchOption.AllDirectories);
        List<string> mmePaths = new List<string>();
        var ttiBasepath = UtilDefine.GetAppValueToString("dataImportFileObserverDirectory");//
        var fileName = testRequestId + "-TTI" + DateTime.Now.ToString("-yyyy-MM-dd_hh-mm-ss") + ".json";
        var filePath = Path.Combine(ttiBasepath, fileName);
        var defaultPath = Path.GetDirectoryName(mmeFiles[0]);
        var defaultName = Path.GetFileNameWithoutExtension(mmeFiles[0]);
        var outputFileName = defaultName + "-" + DateTime.Now.ToString("-yyyy-MM-dd_hh-mm-ss");
        var diademFilePath = Path.Combine(defaultPath, "Result");
        var excelFilePath = Path.Combine(defaultPath, "Report");

        //MacroTTIServerViewModel _data = new MacroTTIServerViewModel()
        //    DataFiles = mmePaths,
        //    TypeOfTheTest = "Custom",
        //    Macros = macros,
        //    ExportData = true,
        //    OutputPaths = new TTIServerOutputPathsViewModel()
        //    {
        //        DIAdemFilesName = outputFileName,
        //        DIAdemFilesPath = diademFilePath,
        //        ExcelFilesName = outputFileName,
        //        ExcelFilesPath = excelFilePath,
        //        PDFReportFilesName = outputFileName,
        //        PDFReportFilesPath = excelFilePath
        //    }
        //Tried with class , did not work so moved to string approach
        StringBuilder sb = new StringBuilder();
        foreach (var path in mmePaths)
            sb.Append(""" + path.Replace("\","\\") + "",");
        sb.Length--; // Remove the last comma
        foreach(var macro in macros)
            sb.Append(""" + macro + "",");
        sb.Length--; // Remove the last comma
        sb.Append(""DIAdemFilesPath":"" + diademFilePath.Replace("\","\\") + "",");
        sb.Append(""DIAdemFilesName":"" + outputFileName + "",");
        sb.Append(""ExcelFilesPath":"" + excelFilePath.Replace("\","\\") + "",");
        sb.Append(""ExcelFilesName":"" + outputFileName + "",");
        sb.Append(""PDFReportFilesPath":"" + excelFilePath.Replace("\","\\") + "",");
        sb.Append(""PDFReportFilesName":"" + outputFileName + """);
        string json1 = sb.ToString();
        //string json = JsonConvert.SerializeObject(_data);

        using (Impersonation.LogonUser(UtilDefine.GetAppValueToString("NetworkDomain"), UtilDefine.GetAppValueToString("NetworkUser"), UtilDefine.GetAppValueToString("NetworkPassword"), LogonType.NewCredentials))
            using (FileStream fs = System.IO.File.Create(filePath))
                var content = new UTF8Encoding(true).GetBytes(json1);
                fs.Write(content, 0, content.Length);
        response = new JsonResponse(message: "Test path empty", success: false);
    return Json(response, JsonRequestBehavior.AllowGet);

I tried JsonConvert.SerializeObject but did not work so moved to string approach



  1. You are generating a invalid json file! Try to put your json file in!
    The problem is try to put double instead.

    "TypeOfTheTest": "Custom",
    "ExportData": true,
    "DataFiles": [ "C:Temp1.mme" ]
    Parse error on line 4:
    … "DataFiles": [ "C:Temp1.mme" ]

    Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{‘, ‘[‘, ‘]’, got ‘undefined’

    Login or Signup to reply.
  2. I’m unable to debug as the functionality works locally.

    If you need to debug an application running in an IIS server, you can attach a debugger to an IIS instance. Just follow these steps:

    1. Click "Debug" from the menu bar
    2. Click "Attach to Process"
    3. Check the "Show processes from all users" checkbox in the bottom left corner
    4. Select w3wp.exe from the process list Click "Attach"

    Like this:enter image description here

    And according to your code, I think the problem may be user permissions. Please try setting the application pool identity to an administrator and check if this work for you.

    Choose the pool you need to set -> Advanced settings… -> Process Model section -> Identity.

    enter image description here
    enter image description here

    Enter the local administrator name and password.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top