Using this tutorial: http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx
1) The web service is invoked such as Service1.asmx/HelloToYou
The default web service in asp.net however won't load the page with this rewritten url, instead i can only refer to it as: Service1.asmx?op=HelloToYou
How do I implement the so-called url rewrite here?
2) the default asp.net web service: is it JSON format? it's not clear how and where i specify the format.
On the Jquery side i do something like:
$.ajax({
type: "POST",
url: "WebService/Service1.asmx/HelloToYou",
data: "{'name': '" + $('#name').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
AjaxSucceeded(msg);
},
error: AjaxFailed
});
so the content-type is JSON.
In asp.net 3.5, do I have to specifically set the format to JSON or is it JSON by default?
Thanks!
UPDATE: in web service code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace DummyWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod()]
public string HelloToYou(string name)
{
return "Hello " + name;
}
[WebMethod()]
public string sayHello()
{
return "hello ";
}
}
}