im在asp.net mvc上构建管理仪表板。即时消息使用全局资源管理页面,因此当管理员更改html标签的内容时,会将请求发送到服务器以编辑资源。一切正常,直到我添加了多语言资源(.en-Us,.tr-Tr等)。 该页面可以刷新,并且错误仅在15秒后消失。
这是我的c#操作:
public void resEditor(string attr,string newVal)
{
var xmlDoc = new XmlDocument();
string resFile = httpruntime.AppDomainAppPath + @"\App_GlobalResources\Resource1.en-US.resx";
xmlDoc.Load(resFile);
foreach (XmlNode nodee in xmlDoc.DocumentElement.ChildNodes)
{
if (nodee.Name == "data")
{
if (nodee.Attributes["name"].Value == attr)
{
nodee.InnerXml = "<value>" + newVal + "</value>";
break;
}
}
}
xmlDoc.Save(resFile);
}
这是发送更改请求的Ajax
$.ajax({
url: '@Url.action("resEditor","Admin")',type: "POST",[enter image description here][1]
async: false,data: { "attr": ab,"newVal": cd },success: function () {
location.reload(true);
},error: function () {
alert('error dude');
}
});