TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anilananda Chakrabortty
NA
425
78k
Method not Allow
Nov 30 2018 12:28 AM
Can any one help me how to fix this error : Method not Allow in WCF post method through ajax
it is a simple asp.net application not MVC Application. I'm trying to perform CRUD Operation through WCF Service.
Here when im inserting the data then their is no problem but same method i copy for delete (written code for delete) then method not allow error showing .
Please help me any one....
here is me code...
Web.config
<?
xml
version
=
"1.0"
?>
<
configuration
>
<
system.web
>
<
authorization
>
<
allow
users
=
"*"
/>
</
authorization
>
<
compilation
debug
=
"true"
targetFramework
=
"4.6.1"
/>
<
httpRuntime
/>
</
system.web
>
<
system.serviceModel
>
<
services
>
<
service
name
=
"EmpAppAJAX.Service.Service1"
>
<
endpoint
address
=
"rest"
behaviorConfiguration
=
"restb"
binding
=
"webHttpBinding"
contract
=
"EmpAppAJAX.Service.IService1"
>
</
endpoint
>
<
endpoint
name
=
"mexHttpBinding"
address
=
"mex"
binding
=
"mexHttpBinding"
contract
=
"EmpAppAJAX.Service.IService1"
/>
</
service
>
</
services
>
<
bindings
>
<
webHttpBinding
>
<
binding
>
<
security
mode
=
"None"
/>
</
binding
>
</
webHttpBinding
>
</
bindings
>
<
behaviors
>
<
endpointBehaviors
>
<
behavior
name
=
"restb"
>
<
webHttp
/>
</
behavior
>
</
endpointBehaviors
>
<
serviceBehaviors
>
<
behavior
>
<
serviceMetadata
httpGetEnabled
=
"true"
httpsGetEnabled
=
"true"
/>
<
serviceDebug
includeExceptionDetailInFaults
=
"false"
/>
</
behavior
>
</
serviceBehaviors
>
</
behaviors
>
<
protocolMapping
>
<
add
binding
=
"basicHttpsBinding"
scheme
=
"https"
/>
</
protocolMapping
>
</
system.serviceModel
>
</
configuration
>
Service:
[OperationContract]
[WebInvoke(Method =
"POST"
, RequestFormat = WebMessageFormat.Json, UriTemplate =
"AddRoles"
)]
void
AddRole(Roles objRole);
[OperationContract]
[WebInvoke(Method =
"GET"
, ResponseFormat = WebMessageFormat.Json, UriTemplate =
"GetRoles"
)]
List<Roles> GetRoles();
[OperationContract]
[WebInvoke(Method =
"Post"
, RequestFormat = WebMessageFormat.Json, UriTemplate =
"DeleteRole"
)]
void
DeleteRole(Roles objRole);
Ajax Code:
//function for deleting role's record
function
Delele(ID) {
debugger
;
var
ans = confirm(
"Are you sure you want to delete this Record?"
);
if
(ans) {
var
objRole = {
"Id"
: ID,
"RoleName"
:
""
,
"RoleDescription"
:
""
};
debugger
;
$.ajax({
url:
"http://localhost:63665/Service/Service1.svc/rest/DeleteRole"
,
type:
"POST"
,
data: JSON.stringify(objRole),
dataType:
"json"
,
contentType:
"application/json;charset=UTF-8"
,
success:
function
(result) {
alert(
"deleted"
);
},
error:
function
(errormessage) {
debugger
;
alert(errormessage);
}
});
}
}
this is the code for insert the data that time their is no error....
$(
"#btnSubmit"
).click(
function
() {
var
objRole = {
"RoleName"
: $(
"#txtRole"
).val(),
"RoleDescription"
: $(
"#txtRoleDescription"
).val()
};
debugger
;
$.ajax({
url:
"http://localhost:63665/Service/Service1.svc/rest/AddRoles"
,
type:
"POST"
,
data: JSON.stringify(objRole),
dataType:
"json"
,
contentType:
"application/json;charset=UTF-8"
,
success:
function
() {
debugger
;
//console.info(result);
alert(
'Inserted'
);
// getData();
},
failure:
function
(msg) {
console.info(msg);
}
});
});
Please someone help me...
Reply
Answers (
2
)
How to create SQL Data Layer in Vb.net using the WCF service
How to run Default method in postman of wcf