Path To Files Inside Content Folder (ASP.NET MVC)

前端 未结 3 838
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 01:19

There something I still do not understand about how the Content folder works in ASP.NET MVC. To make things clearer I have a few questions:

  1. Is the Content folder t
3条回答
  •  名媛妹妹
    2021-02-04 01:44

    You should make a model object for your controller to return. in this example i am returning SearchPageModel, a class i have created. but lets say this object has a property called imageURL

    but make sure the controller actually returns an ActionResult

    so for example...

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult Search()
        {
            SearchPageModel Model = new SearchPageModel();
    
            // populate the Model properties
            Model.ImageURL = "myjpeg"
    
            return View("Search", Model);
        }
    

    i then pass this model object back to my desired view in this case my "Search" View

    and to display the image, in the view i would add..

    
    

提交回复
热议问题