Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Static Methods in ASP .Net web application -- Is this bad form?

Reply
Thread Tools

Static Methods in ASP .Net web application -- Is this bad form?

 
 
davidjgonzalez@gmail.com
Guest
Posts: n/a
 
      03-10-2006
I have an ASP .NET web application written in VS 2003. The web
application's UI (aspx.cs files) call static WebService accessor
methods.

Example.aspx
MyWebserviceAccessor.CallWebService("foo");



MyWebserviceAccessor.cs
public static string CallWebService(string val)
{
string result = "";
WebService1.WebService1() ws = new WebService1.WebService1();

result = ws.SomeWebMethodCall(value);
return result;
}


My concern is the CallWebService(...) is a static method and if 2 user
trigger the event that executes:
MyWebserviceAccessor.CallWebService("foo"); at the same time, I might
have some data integrity issues between users. Can anyone tell me how
ASP .NET handles static methods in ASP .NET apps? should static methods
be avoided in such applications?
Any links to authoritative texts would also be appreciated.

Thanks

 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      03-10-2006
Since you are using only variables local to the method, you should be fined.
Each thread running the method, will have CallWebService instantiate its own
instances of the variables you are using, so there shouldn't be any issues.


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>I have an ASP .NET web application written in VS 2003. The web
> application's UI (aspx.cs files) call static WebService accessor
> methods.
>
> Example.aspx
> MyWebserviceAccessor.CallWebService("foo");
>
>
>
> MyWebserviceAccessor.cs
> public static string CallWebService(string val)
> {
> string result = "";
> WebService1.WebService1() ws = new WebService1.WebService1();
>
> result = ws.SomeWebMethodCall(value);
> return result;
> }
>
>
> My concern is the CallWebService(...) is a static method and if 2 user
> trigger the event that executes:
> MyWebserviceAccessor.CallWebService("foo"); at the same time, I might
> have some data integrity issues between users. Can anyone tell me how
> ASP .NET handles static methods in ASP .NET apps? should static methods
> be avoided in such applications?
> Any links to authoritative texts would also be appreciated.
>
> Thanks
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBNVlA=?=
Guest
Posts: n/a
 
      03-10-2006
Static fields are an issue, static methods are not. If you want to test this,
add a thread pause in the web service and spawn up two threads in your
ASP.NET app. Then fire both threads one after another with different
parameter values. You will see both return the correct answer.

It is fairly common to have "helper functions" as static methods.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


"(E-Mail Removed)" wrote:

> I have an ASP .NET web application written in VS 2003. The web
> application's UI (aspx.cs files) call static WebService accessor
> methods.
>
> Example.aspx
> MyWebserviceAccessor.CallWebService("foo");
>
>
>
> MyWebserviceAccessor.cs
> public static string CallWebService(string val)
> {
> string result = "";
> WebService1.WebService1() ws = new WebService1.WebService1();
>
> result = ws.SomeWebMethodCall(value);
> return result;
> }
>
>
> My concern is the CallWebService(...) is a static method and if 2 user
> trigger the event that executes:
> MyWebserviceAccessor.CallWebService("foo"); at the same time, I might
> have some data integrity issues between users. Can anyone tell me how
> ASP .NET handles static methods in ASP .NET apps? should static methods
> be avoided in such applications?
> Any links to authoritative texts would also be appreciated.
>
> Thanks
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
integer >= 1 == True and integer.0 == False is bad, bad, bad!!! rantingrick Python 44 07-13-2010 06:33 PM
Bad media, bad files or bad Nero? John Computer Information 23 01-08-2008 09:17 PM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 12 02-23-2005 03:28 AM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 0 02-19-2005 01:10 AM



Advertisments