find a location for property in a new city

Saturday 27 October 2012

Unexpected "string" keyword after "@" character. Once inside code, you do not need to prefix constructs like "string" with "@"

After upgrading an ASP.NET MVC 3 project to MVC 4 I noticed a change in the Razor parser that threw a Parser Error saying: 'Unexpected "string" keyword after "@" character. Once inside code, you do not need to prefix constructs like "string" with "@"'

Firstly this has always working when it was MVC 3 and Razor v1. I may have been getting the syntax wrong all along but if the syntax allowed it was it really wrong?

What I was doing was trying to put some server code in a Razor helper with no surrounding HTML tags, like this example:

@helper Currency1000s(int? value)
{
    if(value == null)
    {
        -
    }
    else
    {
        @string.Format("{0:C0}k", value / 1000.0)
    }
}

Interestingly if I were to replace line 9 with @value all would be fine. Anyway, it is an easy enough fix, you just need to wrap the string.Format in HTML tags or the text tags as I did here:

@helper Currency1000s(int? value)
{
    if(value == null)
    {
        -
    }
    else
    {
        @string.Format("{0:C0}k", value / 1000.0)
    }
}

Follow britishdev on Twitter

65 comments:

  1. Keyword point of view your post gives us some great information, I really like it because first time in my life i am reading this type of information. New Playground tiles Uk for sale visit http://playgroundtilesuk.co.uk/

    ReplyDelete
  2. First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics , i will be always checking your blog thanks. Now i need to my blog, you can play, relax and fun with games at here
    friv games 4
    jogos 6
    friv 5 games
    friv 10

    ReplyDelete
  3. That's amazing dude! Now the local best double glazing companies are doing really well by providing highest quality products and adding latest features for more convenience. Don't they?

    ReplyDelete
  4. These things are very important, good think so - I think so too.. a5 booklet design

    ReplyDelete
  5. Hi there, I discovered your blog per Google bit searching for such kinda educational advise moreover your inform beholds very remarkable for me.. Hotmail Login

    ReplyDelete
  6. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing.. locksmiths in birmingham

    ReplyDelete
  7. I enjoyed over read your blog post. Your blog has nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again 3313 exam questions

    ReplyDelete
  8. We Provide Best Packers And Movers Ghaziabad List for Get Free Best Quotes, Compare Charges, Save Money And Time, Household Shifting Services .
    Packers And Movers Ghazibad

    ReplyDelete
  9. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Oh My Home UK

    ReplyDelete
  10. I found that site very usefull and this survey is very cirious, I ' ve never seen a blog that demand a survey for this actions, very curious... Property Management Sarasota Florida

    ReplyDelete
  11. Wholesale printed custom perfume boxes with the highest quality and affordable prices. Free worldwide Delivery and free Custom Perfume Boxes design.

    ReplyDelete
  12. Buy online wholesale printed custom candle boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

    ReplyDelete
  13. Buy online wholesale printed lipstick boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

    ReplyDelete
  14. Buy online wholesale lipstick boxes and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.

    ReplyDelete
  15. Blackbird packaging provide you with any size, shape design, CBD boxes sooner than any other packaging competitor in the market

    ReplyDelete
  16. Packaging town is a one-stop solution for the short-run Custom Packaging, Wholesale CBD Boxes needs, and supplies at ease.

    ReplyDelete
  17. Blackbird packaging provide you with any size, shape design, custom pet food packaging sooner than any other packaging competitor in the market

    ReplyDelete
  18. direct print mylar bags 3.5g direct print mylar bag, available at Your Supplies. This bag comes with cookies holograms. Heat sealable. Fast Shipping.

    ReplyDelete
  19. gelati bags 3.5g Direct Print on the front and back. % Cali Packs Available at Your Supplies. Heat sealable mylar bags. Fast Shipping.

    ReplyDelete
  20. Blackbird packaging provide you with any size, shape design, cbd lotion boxes sooner than any other packaging competitor in the market

    ReplyDelete
  21. Packaging town is a one-stop solution for the short-run custom apparel boxes needs, and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  22. custom direct printed mylar bags UK in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  23. custom printed mylar bags UK in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

    ReplyDelete
  24. buy men sweatshirts online from wild goat clothing

    ReplyDelete
  25. vaccum cleaners
    Shop for Electronic Goods at Al-Fatah, Pakistan's leading chain of departmental stores. Shop from a huge range of top brands Home Appliances, Smart-tech and Phones and Sound bars from Al-Fatah. Shop from huge range of electronics available at Al-Fatah. Avail Free Delivery on orders above 1000 PKR in selected cities.

    ReplyDelete
  26. buy lahore grocery from alfatah at best prices. get free shipping

    ReplyDelete
  27. buy online zipper hoodie online from wild goat clothing at best prices. Get Free shipping

    ReplyDelete
  28. buy wholesale cbd bath bombs from blackbird packaging at best prices. Get free shipping.

    ReplyDelete
  29. Blackbird packaging provide you with any size, shape design, cookie boxes wholesale sooner than any other packaging competitor in the market

    ReplyDelete
  30. Buy pret collection 2021 online from Ilaha Clothing at best prices. Get free shipping.

    ReplyDelete
  31. Packaging town is a one stop solution for the short-run custom apparel packaging needs and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  32. Blackbird packaging company can provide you with any size, shape design, and bath bomb packaging sooner than any other packaging competitor in the market

    ReplyDelete
  33. Packaging town is a one stop solution for the short-run candle boxes needs and supplies. At affordable prices. Request a free quote now.

    ReplyDelete
  34. buy gym tights online from dshred at best prices. Get free delivery

    ReplyDelete
  35. buy dental care products online at best prices from medisense delivered at your doorstep. Get free delivery

    ReplyDelete
  36. buy men tank tops online from Dshred at best prices delivered at your doorstep. Get free shipping

    ReplyDelete
  37. buy gym tights for women online from dshred at easy prices delivered at your doorstep.get free shipping.

    ReplyDelete
  38. buy cosmetics in Pakistan from alfatah at best prices delivered at your doorstep. get free delivery

    ReplyDelete
  39. buy baby care products online online from medisense at best prices deloivered at your doorstep. get free shipping

    ReplyDelete
  40. Buy citizen ch 453 bp monitor price in pakistan at easy prices from medisense delivered at your doorstep. Get free shipping.

    ReplyDelete
  41. Buy baby food online at easy prices from medisense delivered at your doorstep. Get free shipping.

    ReplyDelete
  42. Buy hair care supplements at easy prices from medisense delivered at your doorstep. Get free shipping.

    ReplyDelete
  43. buy inner wear for girls online from dshred at easy prices delivered at your doorstep. get free shipping

    ReplyDelete
  44. buy lounge wear online from Dshred at best prices delivered at your doorstep. get free shipping

    ReplyDelete
  45. Sometimes you just want to relax at home, but how can one relax if they do not feel comfortable? That is why Dshred is offering the most comfortable Women Loungewear products available. Get our knitted loungewear sets for maximum comfort or our Women’s loungewear tracksuits if you plan to go out for a bit.

    ReplyDelete
  46. buy sports bra online in Pakistan from dshred at easy prices delivered at your doorstep. Get free shipping

    ReplyDelete
  47. buy electronics online in lahore from Al-Fatah at best prices delivered at your doorstep. Get free shipping

    ReplyDelete
  48. Buy home appliances at best prices from Al-Fatah delivered at your doorstep. Get free shipping

    ReplyDelete
  49. Buy home appliances at best prices from Al-Fatah delivered at your doorstep. Get free shippingvvvvvvvvvvv

    ReplyDelete
  50. Buy dog food online from Al-Fatah at best prices delivered at your doorstep. Get free shipping

    ReplyDelete
  51. Buy online Latest fashion shorts pakistan from Ndure. Fast Shipping.

    ReplyDelete
  52. Buy online Latest fashion trouers for women from Ndure. Fast Shipping.

    ReplyDelete
  53. From Ndure buy the best quality men cotton t-shirts online. Quick delivery.

    ReplyDelete
  54. Buy grocery in Pakistan at best prices delivered at your doorstep. get free shipping

    ReplyDelete
  55. Since the web developers charged on an hourly basis in most of the cases, the total cost dropped directly in proportion with the decrease in incorporation of tools and softwares. mediajx com

    ReplyDelete
  56. Shop afrozeh 2022 online in Pakistan at Highway Fashion. Buy Afrozeh collection Online In Pakistan. Latest collection luxury edition now available.

    ReplyDelete
  57. We recently covered the importance of professional website design as well as how a website design company can help you benefit from a customized website. A professional website design company can assist you in leveraging the power of the Internet in a number of ways. Website Design Company Dubai

    ReplyDelete
  58. Want To Approach An Affordable Garage Door Roller Replacement Arkansas? Feel Free To Call Us, As We Provide You With Professional Services In This Matter. Whether Your Door Is Misaligned, Broken, Or Their Springs Or Cables Are Not Doing Well, We Can Fix It For You.

    ReplyDelete
  59. noticed a change in the Razor parser that threw a Parser Error saying: 'Unexpected "string" keyword after "@" character.
    visit link my websiteTel-U

    ReplyDelete
  60. your doorstep. Get free shipping
    Chack

    Seo Expert Google,

    ReplyDelete
  61. I enjoyed over read your blog post. Your blog has nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again. Please visit here Ceramic Butterfly Valve

    ReplyDelete