This project is read-only.

Compiler Problems with <%:

Aug 11, 2010 at 7:23 PM


Firstly apologies if I am repeating anything previously writen on this subject.

I am new to ASP.Net and C# and have been following the music store tutorial and all has gone well untill I reach listing the genra.  When I click the "Store" link I am presented with:

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: CS1525: Invalid expression term ':'

Source Error:

Line 9:      <h3>Browse Genres</h3>
Line 10: 
Line 11:     <p>Select from <%: Model.NumberOfGenres %> genres:</p>
Line 12:     
Line 13:     <ul> 

Source File: f:\My Work\Visual Studio\Web Applications\MvcMusicStore\MvcMusicStore\Views\Store\Index.aspx    Line: 11

From what I can understand it doesn't like the colon after the <%:

Can anyone please advise me on this error?



Aug 11, 2010 at 10:45 PM
Dave - HTML Encoded Code Expressions (the long name for the <%: %> syntax) require ASP.NET 4. If you're working in ASP.NET 3.5 SP1, you'll need to use <%= %> and remember to HTML encode user input as necessary. More info here: - Jon
Aug 11, 2010 at 11:11 PM

Thanks Jon, I think I did choose 3.5 as the servers that I have access to use 3.5.

Its a bit late now but will change the code in the morning and let you know how it goes.


Aug 12, 2010 at 10:14 AM

Hi Jon,

Worked a treat, thanks