Reference in .aspx file causes server error

  • Thread starter Thread starter Waldy
  • Start date Start date
W

Waldy

Hi there,
I have a Web Application that uses a reference to a localhost
web service. If however, I try to insert C# code blocks into the .aspx file
I get an error when the application runs because localhost is unknown.
Anyone know how to use a reference in a code block?
 
Hi there,
             I have a Web Application that uses a reference to a localhost
web service.  If however, I try to insert C# code blocks into the .aspx file
I get an error when the application runs because localhost is unknown.
Anyone know how to use a reference in a code block?

did u check the webservice first? .
 
did u check the webservice first? .

Yes, the web service is fine. It works in the code behind file, but not in
a code block. Is this a known limitation of ASP.Net?
 
I noticed that the Web Service reference does not colour the class name in
the code block like it does in the code behind file. I appears as though
the code blocks are not in the project namespace. If I add the namespace to
the reference like so,

MyNameSpace.localhost.TheWebService

the class name part becomes coloured, but it now crashes with a different
error:

Cannot create/shadow copy 'LogCall' when that file already exists
 
The cannot create/shadow copy ... error message was a red herring. It went
away after I did a Clean and Rebuild.
So to sum up, if you need to access a web service in an .aspx code block,
you need to qualify the webservice name with the namespace name where the
reference has been added.
 
Back
Top