Unable to add a web reference to C#.NET desktop application

Posted on 2009-02-16
Last Modified: 2012-05-06
My company made a very large set of changes to over 500 databases and lots of applications and web services over the weekend, having to do with tightened security on web service access.  Suddenly I find myself unable to compile an application that used to work.

In my solution, I have an application project and a web service.  When I build just the web service, it builds with no errors.  When I go to add a web reference to that service into my application project, it throws this error:

"The type of page you have requested is not served because it has been explicitly forbidden.  the extension '.asmx' may be incorrect"

I have a couple of dozen applications that I am supporting, and most of them still compile just fine, *including* one which has a reference to this same web service.  So I must conclude that the problem is in the solution/project, not the web service.

Can anyone give me an idea of where to look for the problem?
Question by:FrancineTaylor
    LVL 7

    Accepted Solution

    If this was happening to me, I would start doing process of elimination kind of stuff.

    OK, so you said you have another application which is referencing the web service fine. Perhaps the solution referencing the web service has some type of problem.

    Ok, make a hello world web service and try to reference it from the problem application. Did it work?

    Also have you tried creating the web reference from the command line. This is the way we do it, works great. It so much less of a headache for me.

    Here is an example of how we do it. It's so much easier to reference an actual code file in your application. When changes are make to the web service you simply run a batch file and it updates the source file.
    "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\wsdl" /language:C# /out:OurWebSite\App_Code\MyWebServiceProxy.cs http://localhost/MyWebService/MyWebService.asmx?WSDL
    LVL 6

    Expert Comment

    Have you tried deleting the web reference and then adding it again? I know this solved 70% of the issues I have with adding web references.
    LVL 7

    Expert Comment

    Also what happens if you browse to the url from the develoment machine. Does it come up? If so are you able to get the WSDL from your web browser? Try it by adding ?WSDL to the end of the url.

    LVL 1

    Author Comment

    Yes, actually, deleting the web service and trying to re-add it was what caused the error.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now