tags:

views:

39

answers:

3

I'm trying to test if ASP.NET is working on my customers IIS 7.5 server, the code below works fine on my server.

<html>
<body bgcolor="yellow">
<center>
<h2>Hello</h2>
<p><%Response.Write(now())%></p>
</center>
</body>
</html>

Using the exact same text.aspx file containing the above code he gets the error:

Compilation Error 
Description: An error occurred during the compilation of a resource required to 
service this request. Please review the following specific error details and 
modify your source code appropriately. 

Compiler Error Message: CS1002: ; expected

Source Error:

    Line 3:  <center>
    Line 4:  <h2>Hello</h2>
    Line 5:  <p><%Response.Write(now())%></p>
    Line 6:  </center>
    Line 7:  </body>

Source File: c:\inetpub\wwwroot\myapp\test.aspx    Line: 5 

Any ideas why this would be? His server will be running a Swiss version of Windows (if that makes any difference).

Many many thanks. Steven

+2  A: 

Check the default language setting in IIS Manager. I think you will find your local machine is set to Visual Basic and the remote server will be set to C#.

IIS 7 and later

  1. Select the web site in question
  2. Select .NET Compilation
  3. Compare the setting value for 'Default Language'

Basically your statement is Visual Basic.

<%= Response.Write("Blah") %>

This is the same statement in C#

<%= Response.Write("Blah"); %> 
David Christiansen
+5  A: 

Your problem is with the following line:

<p><%Response.Write(now())%></p>

The statement needs a semicolon since you're strictly writing a C# statement (rather than using any of the binding expressions):

<p><% Response.Write(now()); %></p>

Whoops...missed part of the question.

If this is working on your local server but not the client's remote server, you should make sure that the client's remote server is set to use Visual Basic instead of C# as the language.

You can also add the Language directive directly to the *.aspx page to force the page to use the correct language:

<%@ Page Title="Your page's title" Language="VB" %>
Justin Niessner
Why did it work on my server? Thanks
Steve Wood
@Steven - See my edit. I missed that part of the question. Got distracted by the code. :-P
Justin Niessner
Great answer, thanks for the help.
Steve Wood
A: 

On my setup this needs to be:

Response.Write(now());

Please note the ; on the end of the Response.Write. What version of Windows Server / ASP.NET is install?

Stephen J. Webb