ASP.Net Web Service Error: Method Not Allowed

Last Reply 7 months ago By nauna

Posted 7 months ago


I have project and in it i have a file service1.svc, i am trying to insert data using http method but it is giving me error method not allowed. 

i am using below code to insert data when i run it in browser with following URI 


[WebInvoke(UriTemplate = "/UserInsert/{UserName}/{Password}/{Email}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public string message { get; set; }
public void userinsert(string UserName, string Password, string Email)
    int userId = 0;
    string constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
    using (SqlConnection con = new SqlConnection(constr))
        using (SqlCommand cmd = new SqlCommand("Insert_User"))
            using (SqlDataAdapter sda = new SqlDataAdapter())
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Username", UserName.Trim());
                cmd.Parameters.AddWithValue("@Password", this.Encrypt(Password.Trim()));
                cmd.Parameters.AddWithValue("@Email", Email.Trim());
                cmd.Connection = con;
                userId = Convert.ToInt32(cmd.ExecuteScalar());
        switch (userId)
        case -1:
            message = "Username already exists.Please choose a different username.";
        case -2:
            message = "Supplied email address has already been used.";
            message = "success."; 

it gives me error method not allow 

Please advice

Posted 7 months ago Modified on 7 months ago

Posted 7 months ago

its working now i was missing Method tag in the code

thanks for your help

[WebInvoke(Method = "POST", UriTemplate = "/UserInsert/{UserName}/{Password}/{Email}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]