Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm getting this error on my sharepoint web application (I'm calling my own web method through ajax on my own user control) while accessing it from another computer and I'm getting this error: “{“Message”:”There was an error processing the request.”,”StackTrace”:”",”ExceptionType”:”"}”

I've read that I need to install ASP.NET AJAX 1.0 on my MOSS 2007 Server to get this to work. Is it true?

Thanks

Edit:

Here's my ajax call:

var Item = {
            emailSubject: jEmailSubject,
            emailBody: jEmailBody,
            userName: jUserName
        };

$.ajax({
            type: "POST",
            url: "/_layouts/WebPartPages/qadrs-webservicepage.aspx/SendEmailToAdmin",
            data: JSON.stringify(Item),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            error: function(error) {
                alert(error.responseText);
                return false;
            },
            success: function(response) {
                if (response.d == "Success") {
                    alert('Email Sent to Administrator');
                    $('#<%=txbEmailSubject.ClientID %>').val('');
                    $('#<%=txtbEmailBody.ClientID %>').val('');
                    window.location = $('#<%=hdnUrlReferrer.ClientID %>').val();
                }
                else if (response.d == "NoEmailAddress") {
                    alert('No email address defined for admin users / user group admin is not configured in web config file. Email not sent.');
                    return false;
                }
                else if (response.d == "Error") {
                    alert('Error while trying to send email to admin.');
                    return false;
                }
            }
        });

My Web Method:

public string SendEmailToAdmin(string subject, string body, string userName, int groupId)
        {
            string returnMessage = string.Empty;
            string adminEmailAddresses = string.Empty;
            int rowCounter = 0;
            string fromEmail = string.Empty;
            string fromName = string.Empty;

            DataSet ds = UserDAL.GetInstance().GetAllUserEmailByUserGroupId(groupId, Common.GetInstance().StripDomain(userName), ConnectionString(""));

            try
            {
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    fromEmail = item["user_email_address"].ToString();
                    fromName = item["user_title"].ToString();
                }


                foreach (DataRow item in ds.Tables[1].Rows)
                {
                    if (rowCounter == 0) adminEmailAddresses += item["user_email_address"].ToString();
                    else adminEmailAddresses += "," + item["user_email_address"].ToString();
                    rowCounter++;
                }

                if (rowCounter == 0) returnMessage = "NoEmailAddress";
                else
                {
                    MailMessage mail = new MailMessage();
                    mail.From = new MailAddress(fromEmail, fromName);
                    mail.To.Add(adminEmailAddresses);
                    mail.IsBodyHtml = true;
                    mail.Subject = subject;

                    string newBody = string.Empty;

                    newBody += "<html><head></head><body>" + body.Replace("\n", "<br />") + "</body></html>";
                    mail.Body = newBody;

                    try
                    {
                        SmtpClient mailClient = new SmtpClient();
                        mailClient.Send(mail);
                        returnMessage = "Success";
                    }
                    catch (Exception ex)
                    {
                        returnMessage = "Error";
                        throw ex;
                    }
                }
            }
            catch (Exception exc)
            {

            }

            return returnMessage;
        }
share|improve this question

2 Answers 2

If you are using pure jQuery to hit your web service, there is no need to install ASP.NET Ajax. But if you are using ASP.NET Ajax functionality(like Sys.Net.WebRequest(), or an UpdatePanel, for example), then yes, you do need to install it, because MOSS runs on .NET 2.0, which does not include it.

Having said that, it's impossible to tell what is going on in your case based on what you've said. If you would post some code and indicate where the error is being thrown, that would greatly increase your chances of getting a resolution.

share|improve this answer

You actually need to configure SharePoint 2007 to use .NET Framework 3.5 which is not in use by default. Doing that would enabled you full access to all the goodies.

There are many ways to enable the assembly redirection one being to open the location of the WSS Web Application via Visual Studio and change framework to 3.5 which would add proper entries. Alternatives see here http://www.telerik.com/help/aspnet-ajax/moss-install-aspnet-ajax-35.html, also Tobias Zimmerman has some http://zimmergren.net/technical/moss-2007-add-support-for-ajax-in-your-sharepoint-installation but also here http://zieglers.wordpress.com/2009/02/02/webconfig-entries-for-enabling-ajax-for-sharepoint-2007/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.