Saturday, November 07, 2009

Adding web reference in class library – ASP.NET MVC

 

It is change in .NET 3.5 using ASP.NET MVC you can’t find ‘Add Web Reference’ option in right click context menu inside a class library (if you do not have web references in your class library).

But I found how to add .NET 2.0 based web reference through adding Service Reference, I quoted the following sentence from a forum thread.

As for the "Add Service Reference", it is used for creating client proxy of WCF service(it will generate a client proxy class). Also, since WCF include webservice communication ability, you can use it to create  client proxy for webservice too.

 

Below are steps I used to add web reference to a web service in class library in my ASP.NET MVC solution.

  1. Right click ‘References’ folder under class library project (there is no Add Web Reference option) instead select ‘Add Service Refrence’
    1
  2. In Add Service Reference window click Advanced… button
    2
  3. in Service Reference Setting Window click Add Web Reference button
    3
  4. Now you are landing on regular .NET 2.0 Add Web Reference window and you can provide a web service URL to be added to your class library.

by adding web reference and from now on you can see ‘Add Web Reference’ option in the right click context menu of Reference folder

4

 

 

 

 

and also Visual studio will create a Web References folder underneath your class library.

4 comments: