2011-12-22 35 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