Tuesday, July 22, 2025

Some Git Command

git init

git clone https://murlidIndigo@bitbucket.org/indigoconsultingpublicis/hdfc_dcemi_file_extract_order_service.git

git status

git add .         [Add all files]

git commit -m "Commit Message"  [For Commit the files]

git push  [Push changes on repository]

git switch UAT [Change branch]

git fetch [Get Files from Repository of all branches]

git rm -r --cached [Remove caching]

Thursday, April 10, 2025

Read XMl File data With namespace and without namespace

 

Suppose xml files is avaialble like this with namespace

<?xml version="1.0" encoding="UTF-8"?> <Document xmlns="http://abcd.org/onmags/schema"> <AuthReq> <MyData> Hi How are you </MyData> </AuthReq> </Document>

.Net Sample Code looks like this

#region With Namespace XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("/Sample/request.xml")); var nms = new XmlNamespaceManager(doc.NameTable); nms.AddNamespace("nm", "http://abcd.org/onmags/schema"); XmlNode node = doc.DocumentElement.SelectSingleNode("/nm:Document/nm:AuthReq", nms); //XmlNode node = doc.DocumentElement.SelectSingleNode("/Document/AuthReq"); string request = node.InnerText.ToString(); #endregion =================================================================

Suppose xml files is avaialble like this without namespace

<?xml version="1.0" encoding="UTF-8"?> <Document> <AuthReq> <MyData> Hi How are you </MyData> </AuthReq> </Document>

.Net Sample Code looks like this

#region With Namespace XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("/Sample/request.xml")); XmlNode node = doc.DocumentElement.SelectSingleNode("/Document/AuthReq"); string request = node.InnerText.ToString(); #endregion

Monday, March 3, 2025

Get Validation Error Message, Page.Isvaild False Section

if you wanted to know the route cause of error message then we can write below code in aso.net 

 foreach (BaseValidator validator in Page.Validators)

            {

                if (validator.Enabled && !validator.IsValid)

                {

                    // Put a breakpoint here

                    string clientID = validator.ClientID;

                    string aa = validator.ErrorMessage;

                }

            }

Monday, February 24, 2025

Session Kill on Page Refresh OR On Page/Browser refresh session kill in asp.net with c#

Create a Global Variable

bool IsPageRefresh = false;

Write Below Code on Page Load

  #region To Maintain Refresh event
  //Section of code checks if the page postback is due to genuine submit by user 
  //or by pressing "refresh" or F5
  if (!IsPostBack)
  {
       //Session.Abandon(); Session.Clear();
       ViewState["ViewStateId"] = System.Guid.NewGuid().ToString();
       Session["SessionId"] = ViewState["ViewStateId"].ToString();
  }
  else
  {
      if (ViewState["ViewStateId"] != null && Session["SessionId"] != null)
        {
          if (ViewState["ViewStateId"].ToString() != Session["SessionId"].ToString())
            {
               IsPageRefresh = true;
            }
        }

        Session["SessionId"] = System.Guid.NewGuid().ToString();
        ViewState["ViewStateId"] = Session["SessionId"].ToString();
    } 
    #endregion 

Check Global variable where you made the condition like on events

    #region To Maintain Refresh event
     if (IsPageRefresh)
        {
          Session.Abandon(); Session.Clear();
        }
    #endregion

    if (Session["MyFlag"] == null) Response.Redirect("invalid.aspx?msg=Session expired. ", true);