相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

First, I'll say I am not making this up. I have a web method implemented in a asmx file like this:

[WebMethod]
[SoapDocumentMethod(OneWay=true)]
public void Method1(INPUT oInput)
   // Call SQL stored procedure SP1
   // Call SQL stored procedure SP2

Using SQL Server Profiler I see stored SP1 get called, but SP2 does not. If I set OneWay=false, both SP1 and SP2 get called.

Here's the weird part. I leave OneWay=true but I set <trace enabled="true"> over in the web config file, both SP1 and SP2 get called. No really!

I will try posting more sample code after I par it down to the minimums. In the mean time, does anyone know of a bug in ASP.NET 3.5 SP1 that might be causing this?

Charles

I found my own answer. There was some code between SP1 and SP2 that accesses the Context.Current.Request object. Commenting it out fixes my issue.

Conclusion? It seems the Request object is unavailable if OneWay=true. Strange though that setting <trace enabled="true"> makes the object available.

From documentation of OneWay property:

Do not have access to HttpContext using the static Current property. To access the HttpContext, derive the class implementing the XML Web service method from WebService and access the Context property.

That makes sense -- when OneWay=true, the Response is returned before your WebMethod is even kicked off. Glad you figured it out. – Moose Apr 30, 2009 at 21:36 I'll investigate, but I'm suspecting this is not the cause. I'm using SQL server authentication with a connection string like "server=Server;database=Database;uid=User;pwd=Password". It seems the running ASP.NET thread context would have no effect when accesses SQL this way. – Charles Apr 30, 2009 at 17:23

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

 
推荐文章