XML文件无法通过Asp.net更新 [英] XML Files is not getting updated through Asp.net

查看:75
本文介绍了XML文件无法通过Asp.net更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过asp.net中的编辑器更新xml文件,但没有更新.
它在本地和开发服务器上工作正常,但在生产服务器上不工作.

我正在将代码粘贴到此处,以帮助我解决问题.


我这样做是因为,一旦我单击CorporateCharities.aspx页面的更新"按钮,我就被抛出到login.aspx页面,因此我为登录页面的页面加载编写了以下代码.


Hi There i am trying to update my xml file through a editor in asp.net but does not updates.
It works fine on Local and Development server.but not working on production server.

I am Pasting my code Down here help me with it.


This i Did because as soon as i click on Update button of my CorporateCharities.aspx page i was getting thrown to login.aspx page so the below code i wrote for page load of login page.


string reseturl = Request.QueryString["ReturnUrl"];
if (reseturl != null)
{
   string newstring = reseturl.Replace("%2f","");
   Response.Redirect(newstring);
}



现在,"CorporateCharities.aspx代码"页面



Now the Code for CorporateCharities.aspx page

private void WriteToItemDataset(string ItemNo)
{
    DataSet ds = new DataSet();
    DataTable dt = new DataTable("Items");

if (Session["dtItemData"] != null)
{
    dt = (DataTable)Session["dtItemData"];
}
if (ItemNo != string.Empty)
{
    foreach (DataRow row in dt.Rows)
    {
        if (!Convert.ToBoolean(row["DeletedFlag"])&& ItemNo == Convert.ToString(row["ItemNo"]))
        {
            row["ItemDescription"] = Editor3.Value;
            dt.AcceptChanges();
            break;
        }
    }

 DataView dv = dt.DefaultView;
dv.Sort = "DeletedFlag,ItemNo";
Session["dtItemData"] = dt;
string Filepath = Server.MapPath("~/CorporateCharities_Content.xml");

if (File.Exists(Filepath))
{
   dt.WriteXml(Filepath,true);
   this.errorMessageHtmlCell.Attributes.Add("style", "color:Green");
   this.errorMessageHtmlCell.InnerText = "Record(s) saved successfully.";
}
else
{
   this.errorMessageHtmlCell.Attributes.Add("style", "color:Red");
   this.errorMessageHtmlCell.InnerText = "File Not Found.";
}




不知道生产服务器中发生了什么.

帮帮我.

谢谢.




Do not know what happening in production server.

Help Me.

Thank You.

推荐答案



请在您的项目中添加日志记录",以便所有异常都应记录在日志文件中.这就是解决问题的方法.

但是我想到的第一件事就是仅文件写入权限...请在生产服务器中签入.

谢谢
-amit.
Hi,

please add Logging in your project so that all exceptions should be logged in log file. that is the way of getting problem.

but first thing come in my mind is about file write permission only... do check in your production server.

thanks
-amit.


您是否检查了执行用户是否对放置XML文件的路径具有写权限?

我看到您已将文件放置在应用程序根目录下,并且通常IIS用户(IUSR _ ********)对应用程序目录没有写权限.

为什么需要将XML文件放在应用程序路径中?探索是否可以将此文件放置在其他文件服务器上的共享路径上并进行访问.与您的服务器管理员联系,以了解文件系统访问的准则.

并且,编写用于异常处理和日志记录的代码,以便您可以跟踪正在发生的事情.

HTH!

如果这解决了您的问题,则标记为答案.
Did you check if the executing user has write access to the path where the XML file is placed??

I see that you have the file placed under the application root and in general IIS user (IUSR_********) will not have write access to the application directory.

Why do you need to place the XML file in the application path? Explore if you can place this file on a share path on someother file server and access it. Talk to your server administrator to find out the guidelines for file system access.

AND, write code for exception handling and logging so that you can find track what is happening.

HTH!

Mark as answer if this solved your issue.


未设置写入权限

感谢您的宝贵时间.

希望对其他人有帮助

iis->转到您的网站虚拟目录->右键单击->设置权限或类似的东西->选择您的网站->
编辑权限->设置写入权限->应用即可.
The Write Permission was not Set

Thanks All For ur valuable time.

Hope it helps to Others

iis ->go to your website virtual Directory -> Right click -> set Permission or something like that -> select your website ->
Edit Permission->set Write permission ->Apply and thats it.


这篇关于XML文件无法通过Asp.net更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆