2011-12-22 36 views
0

我試圖使用顯示燈箱與邏輯是這樣的圖像:爲什麼我會收到Lightbox MVC剃鬚刀錯誤?

public ActionResult displayImg() 

    string lbx = "<a href=\"~/Content/Images/lighthouse.jpg\" rel=\"lightbox\"></a>"; 
    return View (lbx); 

但它給出了一個錯誤:

Server Error in '/' Application. 
-------------------------------------------------------------------------------- 

Illegal characters in path. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Illegal characters in path. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
+0

該代碼沒有任何意義。它也與剃刀無關。 – SLaks 2011-12-22 16:41:41

+0

@ user1112006 - 如果要在頁面上顯示圖像,請呈現''標記。你也不能在發送給瀏覽器的文本中使用'〜'語法 - 它需要被替換爲服務器端。 – 2011-12-23 09:19:28

回答

0

你傳遞<a ...></a>作爲視圖名稱 ,在您的項目中翻譯成文件名。
這不是一個有效的文件名。

您可能想要返回Content(...),它返回一個文字字符串。
您還需要使用URL類映射路徑。

+0

謝謝。我有.cshtml中的所有用於lightbox jquery的腳本,並且在更改爲返回Content(lbx)時,頁面變得空白。還需要 abc它需要再次點擊'abc'。我們如何只顯示圖像而不用點擊?你能提供代碼細節嗎?謝謝 – user1112006 2011-12-22 17:10:48

+1

你的代碼沒有任何意義。你需要弄清楚你想要做什麼並編寫代碼。 – SLaks 2011-12-22 17:34:20