2

What am I doing wrong? How come <%= this %> isn't being interpreted as C#?

Here's the code : Hosted by imgur.com

And here is what it renders (notice the Firebug display): Hosted by imgur.com

What do you think is going on? MVC newb here. :(

And the static Site class: Hosted by imgur.com

(If you cannot see the screenshots on the page, view source and use the URLs from the <img> tags.)

2
  • and what url did you request? ps: seems like now pictures are out of sync: 2nd cannot be generated (i bet so) with 1st code. Commented Apr 29, 2010 at 3:51
  • As zerkms said, how are you requesting the page from your application? What are the routing specifics? Commented Apr 29, 2010 at 4:09

4 Answers 4

5

<%: %> starts with .NET v4

For pre-v4 it's equivalent is <%= Html.Encode(...) %>

Sign up to request clarification or add additional context in comments.

1 Comment

4

The problem was that I was using <%= %> (or even <%: %>) within a tag that had runat="sever".

Comments

2

Shouldn't that be <% %> or <%= %> for a shorthand of Response.Write?

Here's an MSDN article on Embedded Code Blocks.

2 Comments

<% %> is straight code to execute, setting variables, loop constructs. <%= %> is the equiv of <% Response.Write(...) %> <%: %> is the equiv of <% Response.Write(Html.Encode(...)) %>
@DevelopingChris Neat, can't wait to get the upgrade approved. Should be somewhere around 2012.
0

This sometimes happens to me when embedding code inside of html attributes. I've never quite pinned down the exact cause but sometimes you can get around it by using single quotes rather than double.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.