Bug 337674

Summary: Web Handler is not build /run properly
Product: [Mono] MonoDevelop Reporter: Forgotten User gxNgjAWAcH <forgotten_gxNgjAWAcH>
Component: projectAssignee: MD Bugs <monodevelop-bugs>
Status: RESOLVED DUPLICATE QA Contact: MD Bugs <monodevelop-bugs>
Severity: Normal    
Priority: P5 - None    
Version: 0.16 (Beta 1)   
Target Milestone: ---   
Hardware: Other   
OS: openSUSE 10.3   
Whiteboard:
Found By: Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Forgotten User gxNgjAWAcH 2007-10-29 21:32:03 UTC
When creating a new web handler with a codebehind class, the build works OK, but when you hit the handler with a browser, it produces a runtime error, that the class is not found. If I move the csharp code from the codebehind file in the .ashx file, it works OK.

Steps to reproduce:
1. Create a new ASP.NET project
2. Set project's runtime to 1.1
3. Create GetPages.ashx (using template Web Handler - there are 2 of them, doing one and the same in 0.16)
4. Create a GetPages.ashx.cs file.
5. Mark .cs file as "Include with Build", and .ashx as "Include with Deployment" - see this is how it is done with web services with codebehind.
6. Move the csharp code from the .ashx to .cs file and implement the members:

file: GetPages.ashx:

<<%@ WebHandler Language="C#" Class="OfflinePages.GetPages" %>

file: GetPages.ashx.cs:

using System;
using System.Web;

namespace OfflinePages
{
	
	
	public class GetPages : System.Web.IHttpHandler
	{
		
		public virtual void ProcessRequest(HttpContext context)
		{
			context.Response.Clear();
			context.Response.Write("Test");
			context.Response.End();
		}
		
		public bool IsReusable { get {return false;}}
	}
}


7. Build and start with xsp on port 8080
8. Hit with browser: http://localhost:8080/GetPages.ashx

Expected result: To display "Test" in the browser

Actual result: Runtime error:

Server Error in '/' Application
Could not load type 'OfflinePages.GetPages'.

Description: Error processing request.

Error Message: HTTP 500. System.TypeLoadException: Could not load type 'OfflinePages.GetPages'.

Stack Trace:

System.TypeLoadException: Could not load type 'OfflinePages.GetPages'.
  at <0x00000> <unknown method>
  at (wrapper managed-to-native) System.Reflection.Assembly:InternalGetType (System.Reflection.Module,string,bool,bool)
  at System.Reflection.Assembly.GetType (System.String name, Boolean throwOnError, Boolean ignoreCase) [0x00000] 
  at System.Reflection.Assembly.GetType (System.String name, Boolean throwOnError) [0x00000] 
  at System.Web.Compilation.WebServiceCompiler.GetCompiledType () [0x00000] 
  at System.Web.Compilation.WebServiceCompiler.CompileIntoType (System.Web.UI.SimpleWebHandlerParser wService) [0x00000] 
  at System.Web.UI.WebHandlerParser.GetCompiledType (System.Web.HttpContext context, System.String virtualPath, System.String physicalPath) [0x00000] 
  at System.Web.UI.SimpleHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String virtualPath, System.String path) [0x00000] 
  at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context) [0x00000] 
  at System.Web.HttpApplication+<>c__CompilerGenerated1.MoveNext () [0x00000] 

I have verified that:
1. using monodis, the class and the namespace are correct in bin/OfflinePages.dll
2. If I copy the csharp code back in the .ashx file (even if I leave it in the .cs file), this example works.

So, this can be a a bug in xsp or monodevelop, I do not know.

Cheers
Sunny
Comment 1 Forgotten User gxNgjAWAcH 2007-10-30 22:27:26 UTC
I have filed this case to mono as well, as it looks like it belongs there.

https://bugzilla.novell.com/show_bug.cgi?id=337997
Comment 2 Lluis Sanchez 2007-11-05 09:46:46 UTC

*** This bug has been marked as a duplicate of bug 337997 ***