簡體   English   中英

解析googlemap鏈接時出現Razor.Parse錯誤

[英]Razor.Parse error during parsing googlemap link

腳本

在我的應用程序中,我使用Razor.Parse<>().解析文本,鏈接和HTML標記Razor.Parse<>().

string Razor.Parse<TEmail>(string razorTemplate, TEmail model) where TEmail : BaseEmail

我使用'@'來解析來自model數據。 我還解析Web鏈接。 直到我解析了Google Map鏈接,該功能才能正常工作

問題 https://www.google.com/maps/place/New+York,+NY,+USA/@40.6974034,-74.1197634,11z/data=!3m1!4b1!4m5!3m4!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62!8m2! 3d40.7127753!4d-74.0059728鏈接包含' @ '。 所以我得到錯誤:

RazorEngine.Templating.TemplateParsingException: '"40.6974034" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.'

我的嘗試

我嘗試用dobule @@ https://www.google.com/maps/place/New+York,+NY,+USA/@@40.6974034,-74.1197634,11z/data=!3m1!4b1!4m5解析html !3m4!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62!8m2!3d40.7127753!4d-74.0059728但我收到錯誤消息:

RazorEngine.Templating.TemplateParsingException: '"@" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.'

知道該怎么辦嗎? 謝謝

這是因為您試圖傳遞無效的東西。 當使用“ @”關鍵字時,您不能傳遞值,必須傳遞標識符,關鍵字,注釋,“(”,“ {”。“ @”關鍵字標記代碼塊的開始,例如:

string value = Razor.Parse("@UserSession.NumberOfPeople")

上面的可以工作,但是:

string value = Razor.Parse("@http://www.something.com")

將無法使用,這是無效的。

您需要做的是找到替代方案。 您需要使用剃須刀引擎 如果您不知道這是什么,請在這里閱讀。 您不能使用@ ,因為Razor.parse不會轉義字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM