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

+0

@ user1112006 - ページに画像を表示する場合は、「」タグをレンダリングします。また、ブラウザに送るテキストに '〜'構文を使用することはできません。サーバ側に置き換える必要があります。 –

答えて

0

あなたはビュー名として<a ...></a>を渡しているプロジェクトのファイル名に変換されます。
これは有効なファイル名ではありません。

リテラル文字列を返すContent(...)を返すことをお勧めします。
また、URLクラスを使用してパスをマップする必要があります。

+0

ありがとうございます。私は.cshtmlでライトボックスのjquery用のすべてのスクリプトを持っています。そして、Content(lbx)を返すように変更すると、ページが空白になりました。また、 abcで 'abc'をもう一度クリックする必要があります。どのようにクリックすることなく画像を表示するには?コードの詳細を記述できますか?おかげで – user1112006

+1

あなたのコードは意味をなさない。あなたは何をしたいのかを理解し、それを行うコードを書く必要があります。 – SLaks

関連する問題