Skip to content

Instantly share code, notes, and snippets.

View jzwang-dev's full-sized avatar

Wang, Jian-Zhong jzwang-dev

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- 省略... -->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<codeBase version="11.0.0.0" href="bin/V11/Newtonsoft.Json.dll"/>
<codeBase version="12.0.0.0" href="bin/V12/Newtonsoft.Json.dll"/>
</dependentAssembly>
using System;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace VersionConflicts
{
public class MvcApplication : System.Web.HttpApplication
[System.Reflection.Assembly]::LoadFile("C:\Your\DLL\AbsolutePath\Newtonsoft.Json.dll").FullName
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- 省略... -->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
# Updates the Newtonsoft.Json package in every project of the solution to the latest version
Update-Package Newtonsoft.Json
public ActionResult Index()
{
Response.Write(SharedLibrary.Class1.SerializeObject());
Response.Write("<br>");
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(new
{
msg = "序列化自「應用程式」"
}));
return Content("");
}
namespace SharedLibrary
{
public class Class1
{
public static string SerializeObject()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(new
{
msg = "序列化自「共用類別庫」"
});
using System.Web.Mvc;
namespace VersionConflicts.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(new
{
[HttpPost]
public ActionResult SendOrderEmail()
{
var order = Models.OrderUtil.GetTestOrder();
string subject = "測試主旨";
ViewBag.remark = "寄送時間:" + DateTime.Now;
string body = JZLib.JZUtil.RenderViewToString(ControllerContext, "_OrderEmailTemplate", order);
@model Models.Order
@{
Layout = null;
}
訂單編號:@Model.order_id<br>
顧客E-mail:@Model.customer_email<br>
訂單明細<br>
<table border="1" cellpadding="5">
<tr>