Monday, March 26, 2012

Call web service by Javascript in Logon.aspx

I used FormsAuthentication in my ajax-enabled website. Now I wanna call web service (in website) on client-side in Logon.aspx. But I always got an error that is like:

"WebService1" is undifined. (WebService1 is class name in the webservice)

I guess that's because ScriptManager will initialize webservice only after FormsAuthentication. Is this true? I can call webservice client-side in another aspx page.

If no any way for this, I have to give up FormsAuthentication.

Could you show us your code / markup?

You need to authorize anonymous users to access the web service. This can be done in many ways. The easiest way is to add an entry to the web.config file:

<location path="WebService1.asmx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>


Thank you, Rama. It works.

No comments:

Post a Comment