我正在运行一个 MVC 项目并使用 Json,我的代码在 Visual Studio 中运行时可以正常运行,然后我在 IIS 上有一个站点指向同一个文件夹,当从 IIS 站点执行 URL 时,我的代码没有执行与在 Visual Studio 中相同的操作。
在我的代码中,我有:
return JsonConvert.SerializeObject(objectToSerialize);
当我发送 RouteData.Values 时,会产生以下错误:
Error getting value from 'CompiledAssembly' on 'System.CodeDom.Compiler.CompilerResults'.
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at Newtonsoft.Json.JsonConvert.SerializeObject(Object value)
at x.Data.Helpers.Data.JsonHelper.SerializeObject(Object objectToSerialize) in D:\Development\x\x.Data\Helpers\Data\JsonHelper.cs:line 18
我目前正在使用Newtonsoft.Json, Version=11.0.0.0
任何想法发生了什么?IIS 没有 Visual Studio 的功能吗?