我想用剃刀將圖片添加到我的電子郵件中。從我的App_Data文件夾Razor URL.Content拋出錯誤
<img src="@Url.Content("~/app_data/picture.png")" />
使用此代碼,但剃刀不斷拋出此錯誤:
Errors while compiling a Template.
Please try the following to solve the situation:
* If the problem is about missing/invalid references or multiple defines either try to load
the missing references manually (in the compiling appdomain!) or
Specify your references manually by providing your own IReferenceResolver implementation.
See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details.
Currently all references have to be available as files!
* If you get 'class' does not contain a definition for 'member':
try another modelType (for example 'null' to make the model dynamic).
NOTE: You CANNOT use typeof(dynamic) to make the model dynamic!
Or try to use static instead of anonymous/dynamic types.
***More details about the error:
- error: (29, 80) The name 'Url' does not exist in the current context
Temporary files of the compilation can be found in (please delete the folder)***
我想我莫名其妙地失蹤參考的地方,但我在哪裏包括它在哪裏? 任何幫助將非常感激。
更新:我想移動的圖片內容文件夾和更改代碼行
<img src="@Url.Content("~/Content/picture.png")" />
而且仍然沒有運氣。有什麼新的建議?
你爲什麼老是將圖像轉換成app_data? asp.net app_data文件夾是有限制的。您不能從http訪問那裏的文件。 – Murilo
目前,這是我做出的決定的一部分。如果這絕對是一個錯誤的想法,那麼我可以推遲這一點,但我們需要保持在源代碼控制的vs解決方案中 – GDub
反正它不起作用。嘗試在app_data中放置一個文件,然後嘗試使用localhost/yoursite/app_data/test.txt,您將收到權限錯誤。該文件不會在該文件夾內傳送。創建一個文件夾,如內容。 – Murilo