2 Replies - 5047 Views - Last Post: 04 July 2012 - 12:47 AM Rate Topic: -----

#1 idq  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 19-September 11

Return 401 exception from soap service

Posted 03 July 2012 - 06:51 AM

Hi. Is it possible to programmatically return a 401 exception from a web service method when using basicHttpBinding. I tried using:

throw new WebFaultException(System.Net.HttpStatusCode.Unauthorized);


but im only getting HTTP/1.1 500 Internal Server Error in return
Is This A Good Question/Topic? 0
  • +

Replies To: Return 401 exception from soap service

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3666
  • View blog
  • Posts: 11,497
  • Joined: 05-May 12

Re: Return 401 exception from soap service

Posted 03 July 2012 - 09:33 AM

I have know idea if this will be helpful or not since I've never had to deal with something like that before. Can you call this.Context.AddError()?
Was This Post Helpful? 0
  • +
  • -

#3 idq  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 19-September 11

Re: Return 401 exception from soap service

Posted 04 July 2012 - 12:47 AM

View PostSkydiver, on 03 July 2012 - 09:33 AM, said:

I have know idea if this will be helpful or not since I've never had to deal with something like that before. Can you call this.Context.AddError()?


Thanks, I could do the following in the webservice method catch block to make it work

 WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Unauthorized; 

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1