Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6661505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:17:17+00:00 2026-05-26T02:17:17+00:00

I have the following code that works fine on my localhost using IIS7 but

  • 0

I have the following code that works fine on my localhost using IIS7 but when i upload it to my server it is behaving not the same as it did on my localhost
For example the submit button when clicked should check validation which it does on my localhost and then redirects to a URL if the validation is correct

But when the same is tried on the actual server over here
The not working link

the problem started when i introduced a redirect url (in C# code is Response.Redirect(“http://www.google.com”);) in to the c# code…if there is a better way to do this all this hassle wont be necessary..tks

this is the code that i used

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Xml" %>

<script runat="server">


protected void btnSave_Click(object sender, EventArgs e)
{
    txtAddress.Text = "";
    string xmlPath = MapPath("Books.xml");
    XmlDocument doc = new XmlDocument();
    //Check if the file already exists or not
    if (System.IO.File.Exists(xmlPath))
    {
        doc.Load(xmlPath);
        XmlNode bookNode = CreateBookNode(doc);
        //Get reference to the book node and append the book node to it
        XmlNode bookStoreNode = doc.SelectSingleNode("bookstore");
        bookStoreNode.AppendChild(bookNode);
        lblResult.Text = "XML Document has been successfully updated";
        txtAddress.Text = ""; Response.Redirect("http://www.google.com");
    }
    else
    {            
        XmlNode declarationNode = doc.CreateXmlDeclaration("1.0", "", "");
        doc.AppendChild(declarationNode);
        XmlNode comment = doc.CreateComment("This file represents a fragment of a book store inventory database");
        doc.AppendChild(comment);            
        XmlNode bookstoreNode = doc.CreateElement("bookstore");
        XmlNode bookNode = CreateBookNode(doc);                        
        //Append the book node to the bookstore node            
        bookstoreNode.AppendChild(bookNode);
        //Append the bookstore node to the document
        doc.AppendChild(bookstoreNode);
        lblResult.Text = "XML Document has been successfully created";
        txtAddress.Text = "";Response.Redirect("http://www.google.com");
    }
    doc.Save(xmlPath);



}

XmlNode CreateBookNode(XmlDocument doc)
{

    /* 
     XmlNode bookNode = doc.CreateElement("book");
     //Add the genre attribute to the book node
     XmlAttribute genreAttribute = doc.CreateAttribute("genre");
     genreAttribute.Value = txtGenre.Text;        
     bookNode.Attributes.Append(genreAttribute);

     http://www.java2s.com/Code/ASP/XML/SaveformdatatoXMLfile.htm

     */


    XmlNode bookNode = doc.CreateElement("book");

    //Declaration of the Main Node (Particulars)
    XmlNode particularsnode = doc.CreateElement("Particulars");
    //Declaration of Child Nodes in the Main Node(Particulars)
    XmlNode nameNode = doc.CreateElement("Name");
    XmlNode phoneNode = doc.CreateElement("Phone");
    XmlNode emailNode = doc.CreateElement("Email");
    XmlNode AddressNode = doc.CreateElement("Address");
    //Getting the textvalue from the htmlform
    nameNode.InnerText = txtName.Text;
    phoneNode.InnerText = txtPhone.Text;
    emailNode.InnerText = txtEmail.Text;
    AddressNode.InnerText = txtAddress.Text;
    //Updating the XML file here the particularsnode has various children and they are being updated
    particularsnode.AppendChild(nameNode);
    particularsnode.AppendChild(phoneNode);
    particularsnode.AppendChild(emailNode);
    particularsnode.AppendChild(AddressNode);
    bookNode.AppendChild(particularsnode);


    //Declaration of the Main Node (BookParticulars)
    XmlNode bookparticularsnode = doc.CreateElement("BookParticulars");
    //Declaration of Child Nodes in the Main Node(BookParticulars)
    XmlNode schoolNode = doc.CreateElement("School");
    XmlNode currentlevelNode = doc.CreateElement("CurrentLevel");
    XmlNode GABDNode = doc.CreateElement("GiveAwayBookDetails");
    XmlNode LRNode = doc.CreateElement("LevelRequired");
    //Getting the textvalue from the htmlform
    schoolNode.InnerText = txtSchool.Text;
    currentlevelNode.InnerText = txtCurrentLevel.Text;
    GABDNode.InnerText = txtGABD.Text;
    LRNode.InnerText = txtLR.Text;
    //Updating the XML file here the particularsnode has various children and they are being updated
    particularsnode.AppendChild(schoolNode);
    particularsnode.AppendChild(currentlevelNode);
    particularsnode.AppendChild(GABDNode);
    particularsnode.AppendChild(LRNode);
    bookNode.AppendChild(bookparticularsnode);



    return bookNode;
}
public static string NewLineToBreak(string input)
{
    Regex regEx = new Regex(@"[\n|\r]+");
    return regEx.Replace(input, "<br />");
}

protected void txtAddress_Load(object sender, EventArgs e)
{
    txtAddress.Text = "Woodlands Drive 14\n Blk";
}
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:17:18+00:00Added an answer on May 26, 2026 at 2:17 am

    Try using Server.MapPath as describes in ASP.NET Web Project Paths or try using Page.ResolveUrl

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, which works fine on live site, but not on
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I have code that looks like the following, which works fine for displaying the
I have the following line of code that works fine in Firefox, Chrome and
I have the following code (found here) that works fine on it's own <a
I have the following code that works fine i am trying to get the
i have the following code that works fine to put an image in the
I have the following code that works on PHP5 to send a HTTP POST
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
I have the following code that compiles and works well: template<typename T> T GetGlobal(const

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.