0

I am getting this error (at the bottom) when I try to run this code using a generic handler

Jquery Code

 $.post("CheckUserName.ashx?username=Aaron902", 
                    function (result) { 
                        $('#username_availability_result').html('Name already exist!'); 

                        if (result == "exists") { 
                            $('#username_availability_result').html('Name already exist!'); 
                        } 
                        else { 
                            $('#username_availability_result').html('Still available'); 
                        } 

                    }); 

Handler Code

 public void ProcessRequest(HttpContext context) 
        { 
            string user_name = context.Request.QueryString["username"]; 
            string output = "here"; 
            output = CheckUserNameAvailability(user_name); 
            context.Response.Write(output); 
            context.Response.End(); 

        } 

Server Error in '/' Application.

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'Dating.CheckUserName'.

Source Error: Line 1: <%@ WebHandler Language="C#" CodeBehind="CheckUserName.ashx.cs" class="Dating.CheckUserName" %>

Source File: /CheckUserName.ashx Line: 1


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

scripter78
  • 1,117
  • 3
  • 22
  • 50
  • Seems to be an error in the CheckUserName.ashx.cs, can you post the whole .cs file? Did the project compile successfully? – Akos Lukacs Dec 23 '11 at 17:57
  • The parser error says that the loaded assemblies do not have a class called `Dating.CheckUserName` in them. Is the `CheckUserName` class you specified in `CheckUserName.ashx.cs` contained in the `Dating` namespace? If this error is occurring on the production site, have you uploaded your newly built DLLs? – lsuarez Dec 23 '11 at 19:09
  • I'll post the full code when I get home. – scripter78 Dec 23 '11 at 23:20
  • It does compile fine and its not production – scripter78 Dec 23 '11 at 23:21
  • kinda stinks to have to do it this way but this comment box wont allow me to put the full code so you can view it here http://jsfiddle.net/8Fv98/ i know the code is not javascript but hey it works for what i am needing it for and that is just to show what my code is – scripter78 Dec 24 '11 at 16:45

1 Answers1

1

I found a fix to my issue although I am not sure why it works this way and not the original way. All I did was remove the code behind file and put all the code that was there into the ashx file instead of having it in the ashx.cs file.

Of course I removed the directive CodeBehind="CheckUserName.ashx.cs"

Tom van der Woerdt
  • 29,532
  • 7
  • 72
  • 105
scripter78
  • 1,117
  • 3
  • 22
  • 50