Search This Blog

Tuesday, March 24, 2009

Calling ASP.NET web service methods directly from a remote machine

Debugging a web service on my local machine is easy -- write the web service, publish it to my local machine, and then go to "http:\\localhost\webservice1\service1.asmx" to get a convenient prefab test form for entering simple data into the web service.

The prefab form is great for quick testing but unfortunately when you try and access it from a remote machine you get the message "The test form is only available for requests from the local machine."

There's a simple solution. Add these settings to the Web.Config file of the web service application:


<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>


This opens up a big security hole by letting remote users directly access the web service itself so you'd should naturally never do this in a production environment, but for quick-and-dirty testing it's quite useful.

Tuesday, March 3, 2009

Visual Studio 2008 setup projects always require .NET 3.5

I developed a simple console app in Visual Studio 2008 for a client whose XP machines are all running .NET framework 2.0 and sent them a setup program to install it.

Despite my specifically building the app to run under .NET framework 2.0 the setup program told the client that he had to install .NET framework 3.5 before continuing. I checked each dependency of the console app and the setup program itself and in each case it was built to run under .NET framework 2.0.

The solution was pretty out of the way -- in Visual Studio 2008 when building the setup program click on the "View" menu item, then "Editor," then "Launch Conditions" ... that's where the requirement for NET framework 3.5 is. Reset this to NET framework 2.0, rebuild the setup program, and the setup program will be satisfied with NET framework 2.0.