asmx without code behind

V

Veerle

Hi,

I was just wondering: is it possible to write an asmx webservice
in .NET 2.0 without having a code behind file?
So just a xxx.amx file and no xxx.amx.cs file, and as a consequence no
dll's...
If so, anyone can give an example of that, for example an HelloWorld?

Veerle
 
J

Jeroen Mostert

I was just wondering: is it possible to write an asmx webservice
in .NET 2.0 without having a code behind file?

Sure, just drop the CodeBehind attribute and start coding:

<%@ WebService Language="C#" Class="WebService1" %>
using System.Web.Services;

public class WebService1 : WebService {
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}

You may need to explicitly build once before you get IntelliSense.
So just a xxx.amx file and no xxx.amx.cs file, and as a consequence no
dll's...

Keep in mind that there are still assemblies in the background. ASP.NET will
dynamically compile the files in your web site into a temporary assembly.
Having "no DLLs" precompiled also means worse start-up times for your site.
 
V

Veerle

Just curious, why would you want to do that?

RL

I want to put a small and very simple webservice on a web hosting page
which supports asp.net but for which I don't have the rights to
install dll's.
It is just for testing purposes so a little bit less performance is
not an issue.
 
A

Arne Vajhøj

I want to put a small and very simple webservice on a web hosting page
which supports asp.net but for which I don't have the rights to
install dll's.

You do not have access to your own web apps bin dir ?

What about App_Code ?

Arne
 
A

Arne Vajhøj

Just curious, why would you want to do that?

It minimizes the number of files.

Not a particular good criteria for serious software
projects, but very fine for demo stuff.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top