Reputation: 235
I am going to placing .Net web services on customer's web servers. I want to have the web service using uncompiled code (No DLL) so changes can be made on the go. I know this is possible but how do you make this happen? I am assuming I make the asmx = asmx.vb so the code behind is directly in the asmx but I am getting the error that the asmx needs a class (which would usually be in the dll). Any help, suggestions or direction is greatly appreciated.
Upvotes: 0
Views: 2713
Reputation: 3293
Here's a template ASMX file. Copy it and make your changes. Note the Class attribute on the first line needs to match the name of the class in the code.
<%@ WebService Language="C#" Class="MyNamespace.MyClass" %>
using System.Web.Services;
namespace MyNamespace
{
[WebService(Namespace="http://mydomain.example/")]
public class MyClass : WebService
{
[WebMethod]
public void MyFunction()
{
}
}
}
You will then be able to deploy this text ASMX file to the web server without having to supply a DLL. Note that IIS will compile your code but this will happen internally without your having to trigger it.
Also note that Visual Studio (at least my version) won't give you any assistance that you'd be used to such as auto-complete or debug support. In this mode, Visual Studio behaves much like Notepad. You'd be better off developing it with a code-behind file and finally copy/pasting the completed code for deployment.
Upvotes: 1
Reputation: 6582
Website:
The Web Site project is compiled on the fly. You end up with a lot more DLL files, which can be a pain. It also gives problems when you have pages or controls in one directory that need to reference pages and controls in another directory since the other directory may not be compiled into code yet. Another problem can be in publishing.
If Visual Studio isn't told to re-use the same names constantly, it will come up with new names for the DLL files generated by pages all the time. That can lead to having several close copies of DLL files containing the same class name, which will generate plenty of errors. The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be extremely popular.
Web Application:
The Web Application Project was created as an add-in and now exists as part of SP 1 for Visual Studio 2005. The main differences are the Web Application Project was designed to work similar to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build time. In order to update the project it must be recompiled and the DLL file published for changes to occur.
Another nice feature of the Web Application project is it's much easer to exclude files from the project view. In the Web Site project, each file that you exclude is renamed with an exclude keyword in the filename. In the Web Application Project, the project just keeps track of which files to include/exclude from the project view without renaming them, making things much tider.
The article ASP.NET 2.0 - Web Site vs Web Application project also gives reasons on why to use one and not the other. Here is an excerpt of it:
You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
You need to add pre-build and post-build steps during compilation? use Web Application project.
You need to build a Web application using multiple Web projects? use Web Application project.
You want to generate one assembly for each page? use Web Site project.
You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project.
You prefer single-page code model to code-behind model? use Web Site project.
Web Application Projects versus Web Site Projects (MSDN) explains the differences between web site and web application projects. Also, it discusses the configuration to be made in Visual Studio.
Source : ASP.NET Web Site or ASP.NET Web Application?
Upvotes: 1