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

36 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. A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work.Marble India

    ReplyDelete
  4. Good post. I learn some thing tougher on distinct blogs everyday. Most commonly it really is stimulating to learn to read content material from other writers and exercise a specific thing there.Luxury Escapes

    ReplyDelete
  5. Not all are true. Everyone has their own way of thinking but I think they have to reconsider. I like to argue for the most accurate results.
    http://fivenightsatfreddysplay.com

    ReplyDelete
  6. 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
  7. By reading this article I get a lot of lessons and this is very useful . cara menggugurkan kandungan

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

    ReplyDelete
  9. 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
  10. 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
  11. 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
  12. Packers and Movers Pune Provide High Quality ***Household Shifting, Home/Office Relocation, Insurance, Packing, Loading, ###Car Transportation Service Pune and High experiences, Top Rated, Safe and Reliable, Best and Secure Packers and Movers Pune Team List. Get ✔✔✔ Affordable Rate Charts and Compare Quotation and Save Money and Time .
    Packers And Movers Pune

    ReplyDelete
  13. Hire Best Packers And Movers Mumbai for hassle-free Household Shifting, ***Office Relocation, ###Car Transporation, Loading Unloading, packing Unpacking at affordable ✔✔✔ Price Quotation. Top Rated, Safe and Secure Service Providers who can help you with 24x7 and make sure a Untroubled Relocation Services at Cheapest/Lowest Rate
    Packers And Movers Mumbai

    ReplyDelete
  14. Get Packers and Movers Jaipur List of Top Reliable, 100% Affordable, Verified and Secured Service Provider. Get Free ###Packers and Movers Jaipur Price Quotation instantly and Save Cost and Time. Packers and Movers Jaipur ✔✔✔Reviews and Compare Charges for household Shifting, Home/Office Relocation, ***Car Transportation, Pet Relocation, Bike SHifting @
    Packers And Movers Jaipur

    ReplyDelete
  15. Packers and Movers in Delhi -Air wares Packers and Movers could be a metropolis primarily based Packers Movers Company providing reliable and cost-efficient Packers Movers services, Packers and Movers in metropolis and Packing Moving services all told over Republic of India. it's branches all told the most cities of Republic of India. Packers and Movers in metropolis worth the emotions of our customers and thence take that any care, whereas moving and packaging the merchandise of our customers.

    ReplyDelete
  16. Packers and Movers in Delhi - Air payload Packers and Movers may be a Ncr primarily based Packers Movers Company providing reliable and efficient Packers Movers services, Packers and Movers in Ncr and Packing Moving services all told over Asian nation. it's branches all told the most cities of Asian nation..

    ReplyDelete
  17. Motifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium Lawn, Lawn 2019, Best lawn collection, Motifz, Best Lawn in Pakistan, Shipping worldwide. Stitching option available.

    ReplyDelete
  18. Buy Premium lawn Online for Women's at best prices available at Motifz. ✓ Latest Fashion, ✓ Trendy Designs ➤ Shop Now!

    ReplyDelete
  19. 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
  20. Packers and Movers Ahmedabad - We Provide ***Best Service Providers, Safe, Reliable, Affordable, Trusted ###Movers and Packers in Ahmedabad List, Household Shifting, Office Relocation: Choose Top Verified Packers and Movers Ahmedabad Compare ???Shifting Service Chrages, Price Quotation, Rate List Charts and Save Money and Time @ Packers and Movers Ahmedabad

    ReplyDelete
  21. Get Packers and Movers Kolkata List of Top Reliable, 100% Affordable, Verified and Secured Service Provider. Get Free ###Packers and Movers Kolkata Price Quotation instantly and Save Cost and Time. ???Packers and Movers Kolkata Reviews and Compare Charges for household Shifting, Home/Office Relocation, ***Car Transportation, Pet Relocation, Bike SHifting @ Packers and Movers Kolkata

    ReplyDelete
  22. Superb post, we enjoyed each and everything as per written in your post. Thank you for this informative article because it’s really helpful, I really like site.
    Please visit our website: @ Packers and Movers Ahmedabad

    ReplyDelete
  23. janusgames Thanks for sharing such a very good blog and very informative. I found so many interesting stuff in your blog especially its discussion. I like this very much

    ReplyDelete
  24. Get Shifting/Relocation Quotation from ###Packers and Movers Delhi. Packers and Movers Delhi 100% Affordable and Reliable ***Household Shifting Services. Compare Transportation Charges and Save Time, Verified and Trusted Packers and Movers in Delhi, Cheap and Safe Local, Domestic House Shifting @
    Packers And Movers Delhi

    ReplyDelete
  25. This is really unbelievable and extraordinary work. Everyone should read. Thanks for sharing and don't miss WORLD'S BEST

    MotorCycleGame

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

    ReplyDelete
  27. 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
  28. I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. Agen Casino

    ReplyDelete
  29. I like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed... Agen Casino

    ReplyDelete