-2

I have the code below which is basically some embed script code inside an MVC view, everything builds fine but when I run I get this error "The name 'B6' does not exist in the current context", I assume this has to do with the '@' character as this is used with razor to reference variables, I've searched for some way to escape the '@' but have had no luck.

@url = "https://crm.zoho.com/crm/WebFormServeServlet?rid=fwW-@B6-MHnNRgi";

chillydk147
  • 385
  • 1
  • 10
  • 1
    Strange. I did a google search on `razor escape @` and found lots of examples, the first one leading to a question here. Which search terms did you use? – jgauffin Jan 20 '14 at 09:28

2 Answers2

2

Try this in your code

@{string url="https://crm.zoho.com/crm/WebFormServeServlet?rid=fwW-@@B6-MHnNRgi";}

<script src='@url'></script>
Nilesh Gajare
  • 6,302
  • 3
  • 42
  • 73
0

Two solutions:

1) Use @@, which will escape the @ sign.

@url = "https://crm.zoho.com/crm/WebFormServeServlet?rid=fwW-@@B6-MHnNRgi"

2) Use a verbatim string: http://blogs.msdn.com/b/csharpfaq/archive/2004/03/12/what-does-an-before-the-start-of-a-string-literal-mean.aspx

@url = @"https://crm.zoho.com/crm/WebFormServeServlet?rid=fwW-@B6-MHnNRgi"

Tieson T.
  • 20,774
  • 6
  • 77
  • 92