Saturday, 22 September 2018
Tuesday, 18 September 2018
Converting Json Data to Xml Data:
Converting Json Data to Xml Data:
public void xmlSerialize()
{
string json = "{'total': 1, 'city': { 'name': 'Zaafaranah, Red Sea, Egypt, EG', 'dest_code': 'D!001031', 'country': 'EG', 'code': 'C!000001'} }";
System.Xml.XmlDocument xmlDocument = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(json, "city");
System.Xml.XmlTextWriter xmlTextWriter = new System.Xml.XmlTextWriter("json.xml", null);
xmlTextWriter.Formatting = System.Xml.Formatting.Indented;
xmlDocument.Save(xmlTextWriter);
}
public void xmlSerialize()
{
string json = "{'total': 1, 'city': { 'name': 'Zaafaranah, Red Sea, Egypt, EG', 'dest_code': 'D!001031', 'country': 'EG', 'code': 'C!000001'} }";
System.Xml.XmlDocument xmlDocument = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(json, "city");
System.Xml.XmlTextWriter xmlTextWriter = new System.Xml.XmlTextWriter("json.xml", null);
xmlTextWriter.Formatting = System.Xml.Formatting.Indented;
xmlDocument.Save(xmlTextWriter);
}
Friday, 31 August 2018
How to show the timer Control in mvc using Javascript
How to show the time Control in mvc using Javascript ?
Html code :
<p id="demo"></p>
Javascript code :
<script>
var countDownDate = new Date();
countDownDate.getHours(); // => 9
countDownDate.setMinutes(countDownDate.getMinutes() + 30); // => 30
countDownDate.getSeconds(); // => 51
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var minutes = Math.floor((distance % (1000 * 60*60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("demo").innerHTML = minutes + " : " + seconds;
if (seconds <= 0 && minutes <= 0) {
window.location.href = "../User/User_Login";
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
}
</script>
View :
Html code :
<p id="demo"></p>
Javascript code :
<script>
var countDownDate = new Date();
countDownDate.getHours(); // => 9
countDownDate.setMinutes(countDownDate.getMinutes() + 30); // => 30
countDownDate.getSeconds(); // => 51
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var minutes = Math.floor((distance % (1000 * 60*60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("demo").innerHTML = minutes + " : " + seconds;
if (seconds <= 0 && minutes <= 0) {
window.location.href = "../User/User_Login";
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
}
</script>
View :
Tuesday, 28 August 2018
Difference between Web Services and WCF Services?
Web Services vs WCF Services:
WCF Services :
Web Services :
- It is introduced in .net 1.0.
- ASP.NET Web services send and receive messages by using SOAP over HTTP or HTTPS.
- Extension .asmx.
- ASP.NET Web services rely on the XmlSerializer in System.XML.Serialization namespace for serialization .
- Web service Class using [WebService] and Web Method using [web method].
- Web service can be hosted in IIS only.
- Clients for ASP.NET Web services are generated using a command-line tool named WSDL.exe.
- Web services don’t support multi-threading.
- Performance wise web services are slower than WCF service.
WCF Services :
- It is introduced in .net 3.0 .
- WCF services use SOAP by default, but the messages can be in any format, and conveyed by using any transport protocol like HTTP,HTTPs, WS- HTTP, TCP, Named Pipes, MSMQ, P2P(Point to Point) etc.
- Extension .svc
- WCF using System.Runtime.Serialization namespace for serialization.
- WCF Service Class using [ServiceContract] , Method using [OperationContract] and Properties using [DataMember].
- WCF services can be hosted in IIS , WindowsActivation Services(WAS), Managed Windows services or self hosting etc.
- WCF uses ServiceModelMetadata Utility tool,svcutil.exe for the same purpose.
- WCF services Support multi-threading by using ServiceBehaviour class.
- Performance wise WCF services are faster than web service
Web Method Over Loading in Web Service?
- Web Method Over Loading in Web Service?
- [WebService]
- public class CustomerService : System.Web.Services.WebService
- {
- [Web Method]
- public int GetAddtionOfNumber(int a,int b)
- {
- return a + b;
- }
- //overload method
- [Web Method]
- public int GetAddtionOfNumber(int a, int b,int c)
- {
- return a + b + c;
- }
- }
This Error Resolving using message name property:
- [WebService]
- public class CustomerService : System.Web.Services.WebService
- {
- [WebMethod(MessageName = "AdditionOfTwoNumber")]
- public int GetAddtionOfNumber(int a,int b)
- {
- return a + b;
- }
- [WebMethod(MessageName = "AdditionOfThreeNumber")]
- public int GetAddtionOfNumber(int a, int b,int c)
- {
- return a + b+c;
- }
- }
Subscribe to:
Posts (Atom)
Top Agile Interview Questions & Answers
Top Agile Interview Questions & Answers 1. What is Agile Testing? The first question of agile interview question tests your k...
-
Top Agile Interview Questions & Answers 1. What is Agile Testing? The first question of agile interview question tests your k...
-
ASP.NET MVC 5: Logging Exceptions in Database? During application development, we should consider logically correct and incorrect code e...