hello,
i created wcf get method works well but post method is not working
it says method not allowed
please advice me
Post Method
[OperationContract]
[WebInvoke(ResponseFormat =WebMessageFormat.Json, BodyStyle =WebMessageBodyStyle.Bare,
UriTemplate = "InsertMasterTheme/{ThemeName}/{Cost}/{Status}/{html}", Method ="POST")]
public void InsertMasterTheme(string ThemeName, string Cost, string Status, string html)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "INSERT INTO Microwebsite_Theme VALUES(@ThemeName,@Cost,@status,@html)";
cmd.Parameters.AddWithValue("@ThemeName", ThemeName);
cmd.Parameters.AddWithValue("@Cost", Cost);
cmd.Parameters.AddWithValue("@Status", Status);
cmd.Parameters.AddWithValue("@html", html);
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
}
when i call get method it works
[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json)]
public string GetMasterTheme(string prefix)
{
List<object> customers = new List<object>();
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT * FROM Microwebsite_Theme WHERE Status=1 and ThemeName = @prefix OR @prefix IS NULL";
cmd.Parameters.AddWithValue("@prefix", !string.IsNullOrEmpty(prefix) ? prefix : (object)DBNull.Value);
cmd.Connection = conn;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(new
{
Id = sdr["MicrowebsiteThemeId"],
ThemeGUID = sdr["MicrowebsiteThemeGUID"],
ThemeImage = sdr["Themeimage"],
Cost = sdr["Cost"],
html = sdr["html"],
demolink = sdr["demolink"]
});
}
}
conn.Close();
}
return (new JavaScriptSerializer().Serialize(customers));
}
}
end point of get http://handybajo.amtechnology.info/Service/Service1.svc/InsertMasterTheme/name/100/0/abc