こんにちは。
Windows10でASP.NET MVCのアプリケーションを開発しています。
Visual Studio 2017 Communityを使っています。
###前提・実現したいこと
データベースから、リンクを作りたいです。
###試したこと
@Html.ActionLink(“リンクに表示する文字列”, “コントローラのアクション名”, “コントローラ名”, new { アクションに渡すパラメータ }, null)
でできると考えました。
(1)RouteConfig.csを確認。
(2)Index.cshtmlに@Html.ActionLinkを記述。
(3)実行するが、Dashboard/Indexの文字が消えてしまう。
###発生している問題・エラーメッセージ
リンク部分にDashboard/Indexの文字が消えてしまう。
###該当のソースコード
C#
1(1)RouteConfig.cs 2 public static void RegisterRoutes(RouteCollection routes) 3 { 4 routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 5 routes.MapRoute( 6 name: "Default", 7 url: "{controller}/{action}/{id}", 8 defaults: new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional } 9 ); 10 } 11
C#
1Index.cshtml 2@Html.ActionLink( 3 @Html.DisplayFor(modelitem => Model.UsersData[i].ConnectionId).ToString().Trim(), //リンク・テキスト 4 "Index",//アクション名 5 "Dashboard", //コントローラー名 6 new {connectionid = @Html.DisplayFor(modelitem => Model.UsersData[i].ConnectionId).ToString().Trim()},//ルート・パラメータ 7 null //その他属性 8)
できたhtml <a href="/?connectionid="abc">abc</a>
###補足情報(言語/FW/ツール等のバージョンなど)
Microsoft Visual Studio Community 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586
です。
よろしくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/08 04:06
退会済みユーザー
2017/05/08 04:28
2017/05/08 04:33
2017/05/08 04:33
退会済みユーザー
2017/05/08 06:07 編集
2017/05/08 06:20
退会済みユーザー
2017/05/08 06:23
2017/05/08 06:24
退会済みユーザー
2017/05/08 07:49