1

エラーが発生しています:型名 'Models' が型 'System.Web.Helpers.Chart' に存在しません

これを解決するのを手伝ってください。mvc と razor 構文で開発されたコードは次のとおりです。

モデル

  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;

  namespace Chart.Models
  {
            public class FooBarModel
            {
                public IEnumerable<SelectListItem> Locations { get; set; }
            }
  }

コントローラ:

        using Chart.Models;
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.Mvc;

        namespace Chart.Controllers
        {
            public class FooController : Controller
            {
                //
                // GET: /Foo/

                public ActionResult Index()
                {
                    var locations = new[]
                    {
                        new SelectListItem { Value = "US", Text = "United States" },
                        new SelectListItem { Value = "CA", Text = "Canada" },
                        new SelectListItem { Value = "MX", Text = "Mexico" },
                    };

                    var model = new FooBarModel
                    {
                        Locations = locations,
                    };

                    return View(model);
                }       
            }
        }

ここに画像の説明を入力

コードを表示:

        @model Chart.Models.FooBarModel             // intellisense shows error on this line as well

        @{
            Layout = null;
        }

        <!DOCTYPE html>

        <html>
        <head>
            <meta name="viewport" content="width=device-width" />
            <title>Index</title>
            <script>
                var locations = @Html.Raw(Json.Encode(Model.Locations));
            </script>
        </head>
        <body>
            <div>        
            </div>
        </body>
        </html>
4

1 に答える 1