Showing posts with label Web-Service. Show all posts
Showing posts with label Web-Service. Show all posts
Sunday, December 2, 2012

Dynamic URL of asp.net web service with web reference

It’s been a while I am writing this. But never late.. So I am writing this. Before some time one of friend asked about the URL of web service when we add reference. So I am writing this. Some of you may find this very basic but still many of people does not know this that’s why I am writing this.

In today’s world we have so many servers like development, preproduction and production etc. and for all the server location or URL of web service will be different.But with asp.net when you add a web reference to your web application it’s create a web reference settings in web.config where you can change this path. So it’s very easy to just change that path and you don’t have to add web reference again.
Share:
Wednesday, June 27, 2012

Interview questions about ASP.NET Web services.

I have seen there are lots of myth’s about asp.net web services in fresher level asp.net developers. So I decided to write a blog post about asp.net web services interview questions. Because I think this is the best way to reach fresher asp.net developers. Followings are few questions about asp.net web services.

1) What is asp.net web services?
Ans: Web services are used to support http requests that formatted using xml,http and SOAP syntax. They interact with through standards xml messages through Soap. They are used to support interoperability. It has .asmx extension and .NET framework contains http handlers for web services to support http requested
directly.


2) What kind of data can be returned web services web methods?
Ans: It supports all the primitive data types and custom data types that can be encoded and serialized by xml. You can find more information about that from the following link.
http://msdn.microsoft.com/en-us/library/bb552900.aspx

3) Is web services are only written in asp.net?
Ans: No, It can be written by Java and PHP languages also.

Share:
Friday, October 29, 2010

Difference between Web Service and WCF Service

While taking interviews of .NET developers I often ask this questions. But lots of people don’t know exact difference between this. So, I decided to write a separate blog about this.

Here are the few differences.

  • Web services can be hosted in IIS as well as outside of the IIS. While WCF service can be hosted in IIS, Windows activation service,Self Hosting,WAS and on lots of proctols like Named Pipe,TCP etc.Here lots of people disagree how we can host the web service outside of the IIS but Here is the article for that.http://msdn.microsoft.com/en-us/library/aa529311.aspx.
  • In Web Services Web Service attribute will added  on the top of class. In WCF there will be a Service Contract attributes will be there. Same way Web Method attribute are added in top of method of Web service while in WCF Service Operation Contract will added on the top method.
  • In Web service System.XML.Serialization is supported while in the WCF Service System.RunTime.Serialization is supported.
  • WCF Services can be multithreaded via ServiceBehavior class while web service can not be.
  • WCF Services supports different type of bindings like BasicHttpBinding, WSHttpBinding, WSDualHttpBinding etc.while Web services only used soap or xml for this.
  • Web services are compiled into a class library assembly. A file called the service file is provided that has the extension .asmx and contains an @ WebService directive that identifies the class that contains the code for the service and the assembly in which it is located while in WCF.WCF services can readily be hosted within IIS 5.1 or 6.0, the Windows Process Activation Service (WAS) that is provided as part of IIS 7.0, and within any .NET application. To host a service in IIS 5.1 or 6.0, the service must use HTTP as the communications transport protocol.

Hope this will help you. Happy programming!!!

Technorati Tags: ,,
Shout it
kick it on DotNetKicks.com
Share:
Saturday, July 25, 2009

Sending mail with secure service layer in asp.net 3.5/2.0

In earlier post i have mentioned that how to send the email using new System.Net.Smtpmail with asp.net 2.0 or higher version. Now lets learn how to send the mail with the secure service layer in the asp.net.

Security is the one of the most important requirement in today’s world as you are doing your business online you have keep secure from other wrong elements. Secure service layer add an

extra layer of security to your web application and sending mail with the SSL with tighten your security for mails. Your emails are more secure then ever and your valuable information will not going to wrong hands.

Here is the code from which we can send the email with the secure service layer. As i have mentioned in earlier post you need to to send email with authentication to use SSL. So you need to write following code. First you need to create message like following..

MailAddress fromAddress = new MailAddress("[email protected]","Nameofsendingperson");
message.From = @”fromAddress”;//here you can set address
message.To.Add("mailto:[email protected]%22%29;//");//
message.Subject = "Sending email with ssl";
message.CC.Add("[email protected]");//ccing the same email to other email address
message.Bcc.Add(new MailAddress("[email protected]"));//here you can add bcc address
message.IsBodyHtml = true;//To determine email body is html or not
message.Body =@"Plain or HTML Text";
Then you have to sent message with following code.
System.Net.Mail.SmtpClient mailClient =
 new System.Net.Mail.SmtpClient("your smptp","ssl port");
//This object stores the authentication values
System.Net.NetworkCredential basicCrenntial = 
new System.Net.NetworkCredential("username", "password");
mailClient.Host = "Host";
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicCrenntial;
// You have to add one other properties for SSL
mailClient.EnableSSL=true;
mailClient.Send(message);
Share:
Saturday, July 18, 2009

Partial Types, Class and Method in C#.NET 3.0/2.0

With C# 2.0 Microsoft has added partial keyword in C#. So what is partial keyword used for. Lets go through the partial keyword in greater detail.

First and foremost use of the partial keyword is the you can declare one class or method with more then one declaration and at the compilation time it will have one complete class.So now you can declare a class more then one file at the compile time it will be treated as one class.

For example this is one class

//first file Patial Class
public class partial PartialClass
{
   public void First()
   {
     //First function
   }
}
 Here is the another class
public class partial PartialClass
{
   public void Second()
   {
      // Logic...
   }
}
Now at the compile time it will be treat as single class like following.
public class PartialClass
{
   public void First()
   {
      // Logic...
   }
   public void Second()
   {
      // Logic...
   }
}
Same way you can use partial method it will treated as one method as compile time. Partial method will only available with C# 3.0. It will not be available to C# 2.0.

Practical Usage Of Partial Class:

There are lots of way where partial class is useful like many developer can work on same class via creating different files. There are lost of code generators available in market so you can extend the class functionality via marking them partial. Partial class can also be used for the manage code in separate files instead of creating large files. With C# 3.5 linq to sql designer uses this concept to split custom behaviors outside mapping class.

Share:
Wednesday, June 10, 2009

What’s new in asp.net 4.0 and .net Framework 4.0?

Microsoft.NET Framework 4.0 beta version is out now. Let’s see the what’s new in asp.net 4.0 for the developer purpose. There are lots of features are there. Some of them are following.

1) Extensible Output Caching:

ASP.NET 4.0 adds an extensibility to output caching now you can create your cache provider and will can use this provider for the caching. So now you can use your own data source for you caching.

2) AutoStart Webapplication

Before asp.net 4.0 you have to use application_load or application_start event for the extensive data processing before application pages loads. But now you can use auto start features of asp.net 4.0. A new scalability feature named auto-start that directly addresses this scenario is available when ASP.NET 4.0 runs on IIS 7.5 on Windows Server 2008 R2. The auto-start feature provides a controlled approach for starting up an application pool, initializing an ASP.NET application, and then accepting HTTP requests.

3) Permanently Redirecting a page

Before asp.net 4.0 you need to use response.redirect method to go to another page from new page. ASP.NET, developers have traditionally handled requests to old URLs by using by using the Response.Redirect method to forward a request to the new URL. However, the Redirect method issues an HTTP 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URLs. Now permanent redirect will solve this. Its will also benefit for the Search Engine Optimization.

4) Compressed Session State:

ASP.NET 4.0 will have new option for session stored in sql server or in state service. You can compress your serialized session using GZip Compression

5) Page.Keywords and Page.Description Properties

In asp.net 4.0 now you can create dynamic keywords and description for a page using Page.Keywords and Page.Description Properties

6) Enabling View state for Individual Controls

In earlier version of the asp.net if you disable your parent control view state it will disable your child control view state but now with asp.net view state is not dependent on parent child control view state.

7) Routing in asp.net 4.0

Now you can have build in routing for your pages. You don’t have to write your url rewriting modules. It introduces a WebFormRouteHandler routing class which will take care of routing.

8) ClientID

In earlier asp.net version clientId is system generated and if you want to change you have to override it . ASP.NET by default generated a big string for the clientid which will increase your html kb. With asp.net you have small client id using different options Legacy,Static,Predictable,Inherit

There are several other features are also there like following

Live Data Binding

Observer pattern using JavaScript and JavaScript objects

ADONetServiceProxy Class

Formview Control Ehancements

Ajax Improvements in asp.net 4.0

I have just list some of the features you can have all the features available in asp.net 4.0 white paper from the following link.

http://www.asp.net/learn/whitepapers/aspnet40/

Cheers… Happy Programming…

Share:
Wednesday, May 27, 2009

Increase Performance in asp.net application

For every enterprise level application the key to make that application success is the responsiveness of application. ASP.NET also offers great deal of the features for developing web based enterprise application but some times due to avoiding best practice to write application the performance of application performance of application is not so fast as it should be. Here are the some use full suggestion to make your application super fast.

  1. Always set debug=”false” in web.config production environment.
  2. Always set trace=”false” in web.config production environment
  3. If you are using asp.net 2.0 or higher version then always use precompiled version of your code and also prefer web application project over website. If you are using website then always publish it and then upload that precompiled version of your site in production environment.
  4. Always compile your project in Release Mode before uploading application to production environment.
  5. Decrease your html kb as much as you can for that use tables less html using div’s and if possible then do not give big name to your control it will increase your html kb as asp.net uses client Id to differentiate all the controls. If you are creating custom controls then you can overwrite your clientid and uniqueId.
  6. Use cache api as much as possible it will decrease your server roundtrip and boost application performance. ASP.NET 2.0 or higher version provides functionality called sqlcachedependancy for your database caching. It will validate cache with your database operation like insert,update and delete and if not possible with it then use the file base caching.
  7. Remove blank spaces from your html it will increase your kb. You can use regular expression to remove white spaces. I will post the code for removing white spaces next posts.
  8. For asp.net 2.0 and higher version use master pages. It will increase your performance.
  9. Prefer database reader over dataset unless and until you have specific reason to use database.
  10. Use ADO.NET asynchronous calls for ado.net methods. asp.net 2.0 or higher version is supporting your performance. If you are using same procedure or command multiple time then use ADO.NET Prepare command it will increase your performance.
  11. Do IIS performance tuning as per your requirement.
  12. Disable view state for your controls if possible. If you are using asp.net 2.0 or higher version then use asp.net control state instead of view state. Store view state in session or database by overriding the default methods for storing view state.
  13. User Server.Transfer instead of response.redirect.
  14. Always use inproc session state if possible.
  15. Use Ajax for your application wisely. Lots of Ajax calls for a page will also decrease your performance.
  16. Measure your application performance with tools like redgate profiler,firebug and whyslovw from yahoo.
  17. User System.Text.StringBuilder for string concatenation its 4 times more faster then the normal strings.
  18. Right JavaScript in .Js files and place it as bottom of the application.
  19. Use Separate CSS files for styling of application.
  20. User database paging over normal paging while displaying huge amount of data.
  21. Call web service from java script instead of server side. Use asynchronous calls to call a web method from web service.

That’s it!!…..Happy Programming..

Share:
Wednesday, May 21, 2008

Localization in asp.net

I am googling about the localization in asp.net 2.0 and higer version and i found lots of good link for that.

Here is the collection of good link if anybody is looking for it.

ASP.NET 2.0 Localization (Video, Whitepaper, and Database Provider Support)
http://weblogs.asp.net/scottgu/archive/2006/05/30/ASP.NET-2.0-Localization-_2800_Video_2C00_-Whitepaper_2C00_-and-Database-Provider-Support_2900_.aspx

ASP.NET 2.0 Localization Features: A Fresh Approach to Localizing Web Applications
http://msdn.microsoft.com/en-us/library/ms379546(VS.80).aspx

ASP.NET AJAX Localization Slides and Code
http://seejoelprogram.wordpress.com/2008/03/06/aspnet-ajax-localization-slides-and-code/

Building Multilingual Web Sites with ASP.NET
http://www.beansoftware.com/ASP.NET-Tutorials/Globalisation-Multilingual-CultureInfo.aspx

Globalization and localization demystified in ASP.NET 2.0
http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx

Enterprise Localization Toolkit
http://msdn.microsoft.com/en-us/library/aa479334.aspx

How to build Multi-Language Web Sites with ASP.NET 2.0 and VS.Net 2005
http://www.dotnetheaven.com/UploadFile/mosessaur/aspnetlocalization03232006045335AM/aspnetlocalization.aspx

Introduction to Localization in ASP.NET 2.0
http://www.west-wind.com/presentations/wwDbResourceProvider/introtolocalization.aspx

Localization in ASP.NET 2.0
http://aspalliance.com/821

Localization practices for .NET 2.0: It's still about the architecture
http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1278147,00.html#

Arabization: Localization/Globalization in ASP.Net 2.0
http://www.c-sharpcorner.com/UploadFile/munnamax/Localization03172007031927AM/Localization.aspx

Creating multilingual websites - Part 1
http://www.codeproject.com/KB/aspnet/localization_websites.aspx

Localization in ASP.NET 2.0
http://www.ondotnet.com/pub/a/dotnet/2005/08/08/localizingaspnet20.html

Resources and Localization in ASP.NET 2.0
http://msdn.microsoft.com/en-us/magazine/cc163566.aspx

Internationalizing Your Application-ASP.NET QuickStart Tutorial

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/default.aspx

Share:
Friday, February 15, 2008

XML for asp.net

I have found a great resources for developers who are using XML in asp.net frameworks. The site http://www.xmlforasp.net/ having all the thins that require to develop application using XML in asp.net. It has videos, code bank , .NET XML training all the stuff.

Share:

Creating Web Services in a Class Library project

When you are developing a plug in or add in for a software some time you have a requirement for developing webservice hosting in DLL. I have found a great link which describes all the things.

here is the link..

http://www.codeproject.com/KB/aspnet/wsinaclasslibrary.aspx

Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews