Acess拒绝了asp.net中的错误 [英] Acess denied error in asp.net

查看:62
本文介绍了Acess拒绝了asp.net中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个简单的页面,将新闻添加到具有值标题和链接重定向的网站。

我为此目的使用了xml。

我在本地主机上运行代码它工作正常,但是当我在网站上部署时,只要我试图保存文件就会显示aceess拒绝错误。

我的XML文件是

I have made a simple page to add news to a site which has values title and link to be redirect.
I Have use xml for the purpose.
When i run code on local host it is working perfectly but when i deploy it on website it shows aceess denied error whenever i''m trying to save the file.
My XML file is

<?xml version="1.0" encoding="utf-8"?>
<newsInfo>
  <news>
    <id>1</id>
    <title>AGM (Annual General Meeting) was held on 16th June (Saturday), New Executive Committee has taken charge.</title>
    <link>../contact.aspx</link>
  </news>
  <news>
    <id>2</id>
    <title>IETE Surat  center is thinking to hold its first examination center at SURAT in December 2012, For more Information please  send your feedback here.</title>
    <link>../contact.aspx</link>
  </news>
</newsInfo>







和代码是




And code is

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["7856_UserID"] == null)
            {
                Response.Redirect("Default.aspx");

            }
            else
            {
                lblUserName.Text = "Welcome " + Convert.ToString(Session["7856_UserID"]) + "!";
                fillgrid();
            }
        }
    }
    protected DataTable retriveDetailsFromXML()
    {
        XDocument xmlDoc = XDocument.Load(Server.MapPath("~\\Data\\newsInfo.xml"));
        var com = from committee in xmlDoc.Descendants("news")
                  select new
                  {
                      id = committee.Element("id").Value,
                      title = committee.Element("title").Value,
                      link = committee.Element("link").Value,
                  };
        DataTable dt = getTable();
        foreach (var c in com)
        {
            DataRow dr = dt.NewRow();
            dr["id"] = c.id;
            dr["title"] = c.title;
            dr["link"] = c.link;
            dt.Rows.Add(dr);
        }
        return dt;
    }
    protected DataTable getTable()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("id");
        dt.Columns.Add("title");
        dt.Columns.Add("link");
        return dt;
    }
    protected void fillgrid()
    {

        ASPxGridView1.DataSource = retriveDetailsFromXML();
        ASPxGridView1.DataBind();
    }
    protected void btnAddNew_Click(object sender, EventArgs e)
    {
        ASPxGridView1.AddNewRow();
    }
    protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
            DataTable dt = retriveDetailsFromXML();
            XDocument doc = XDocument.Load(Server.MapPath("~\\Data\\newsInfo.xml"));
            doc.Element("newsInfo").Add(new XElement("news", new XElement("id", Convert.ToInt32(dt.Rows[dt.Rows.Count - 1][0]) + 1), new XElement("title", e.NewValues[0]), new XElement("link", e.NewValues[1])));
            doc.Save(Server.MapPath("~\\Data\\newsInfo.xml"));
            fillgrid();
        
        ASPxGridView1.CancelEdit();
        e.Cancel = true;

    }
    protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {

        if (Session["KeyValue"] != null)
        {
            Int32 key = Convert.ToInt32(Session["KeyValue"]);
            XDocument doc = XDocument.Load(Server.MapPath("~\\Data\\newsInfo.xml"));
            IEnumerable<XElement> com = doc.Elements("newsInfo").Elements("news");
            var oCom = (from member in com
                        where member.Element("id").Value == key.ToString()
                        select member).SingleOrDefault();
            oCom.SetElementValue("title", e.NewValues[0]);
            oCom.SetElementValue("link", e.NewValues[1]);
           
            doc.Save(Server.MapPath("~\\Data\\newsInfo.xml"));
            Session["KeyValue"] = null;
        }
        fillgrid();


        ASPxGridView1.CancelEdit();
        e.Cancel = true;

    }
    protected void ASPxGridView1_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
    {
        Session["KeyValue"] = Convert.ToInt32(ASPxGridView1.GetRowValuesByKeyValue(e.EditingKeyValue, "id"));
    }
    protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {
        XDocument doc = XDocument.Load(Server.MapPath("~\\Data\\newsInfo.xml"));
        doc.Element("newsInfo").Elements("news").Where(x => x.Element("id").Value.Trim() == e.Keys["id"].ToString()).Remove();
        doc.Save(Server.MapPath("~\\Data\\newsInfo.xml"));
        fillgrid();

        e.Cancel = true;
    }



任何1可以告诉我wat是问题。


Can any 1 tell me wat is problem.

推荐答案

我没有''看着你的代码,

但是想到的一个显而易见的问题是......



你有写入的权限吗?服务器上的文件夹?
I haven''t looked at your code,
but the obvious question that comes to mind is....

Do you have WRITE access for the folder on the server?


使用此链接 -

http://www.activeservers.com/Set-Perms-Cuteftp.aspx [ ^ ]



并更改文件夹权限

将答案标记为解决方案为了你。 :)
Use This Link-
http://www.activeservers.com/Set-Perms-Cuteftp.aspx[^]

and change Folder permission
mark answer as Solution if this works for you. :)


尝试更改保存文件的文件夹的读/写权限

i也面临问题当我在文件夹中上传图像然后它抛出访问被拒绝异常

所以我改变了你上传文件夹的读/写权限文件正在进行保存。
Try to change the Read/write Permission of Folder where you''re saving your file.
i also faced problem when i was uploading Image in the folder then it was throwing Access is denied Exception
so i changed the Read/Write Permission of Folder where you''re uploaded File is going to save.


这篇关于Acess拒绝了asp.net中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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