blah blah blah is here! blah blah » Close

up0down
link

I have a webservice that I want to limit input to only one of the functions, to posts only... the rest can accept any standard ws input. can anyone point me in the right direction?

last answered 2 years ago

1 answers

up0down
link

I think the functionality can be achieved by implementing the access control in Business logic. (My idea of application is that your aim is to restrict input to a particular module... Am I right!!!)

up0down
link

I'm trying to restrict it to a form post, so that no other method of consuming the service can be used.
there's got to be some sort of attribute or config setting that can achieve this, but since I rarely ever use webservices in .net i dunno.

up0down
link

One way is to set some Session variable and check its status before loading the web service

up0down
link

Modify the web.config for your web service as below:
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpPost" />
</protocols>
</webServices>
Stu

up0down
link

The following will add support for HttpPost and does not allow HttpGet, I need to check if this prevents SOAP requests.
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpPost" />
</protocols>
</webServices>

up0down
link

I now about the protocols bit but is there a way to define this for a single function (setting this specifies an http post for all methods). I was trying to get around this global declaration, but if its the only way then its the only way... I was just hoping for another.
thx

up0down
link

You could do it in code by checking as follows.
if (Context.Request.RequestType != "POST")
{
//Fail
}
else
{
//Succeed
}

up0down
link

this is exactly what I was looking for thankyou!!!
in PHP there is a _POST associative array that allows you to use post variables only and that is what I was hoping for here, so thankyou.

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback