title: How to create EDIT method and EDIT Razor View for Image which i stored in database in VARBINARY datatype in ASP.net MVC?
body: <p>Here is my Create Method</p>
  
  <pre><code>  /*  [HttpPost]
      public ActionResult Create(Image newRecipe)
      {
          try
          {
              using (var db = new  MitishaKitchenContext())
              {
                  db.Images.Add(newRecipe);
                  db.SaveChanges();
              }
              return RedirectToAction("Index");
          }
          catch { return View(); }
      }*/
  
      [HttpPost]
      public ActionResult Create(Image IG)
      {
          // Apply Validation Here
  
  
  
          if (IG == null)
          {
              return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
          }
  
          if (IG != null &amp;&amp; IG.File.ContentLength &gt; (2 * 1024 * 1024))
          {
              ModelState.AddModelError("CustomError", "File size must be less than 2 MB");
              return View();
          }
          if (!(IG.File.ContentType == "image/jpeg" || IG.File.ContentType == "image/gif"))
          {
              ModelState.AddModelError("CustomError", "File type allowed : jpeg and gif");
              return View();
          } 
  
        //  IG.FileName = IG.File.FileName;
        //  IG.ImageSize = IG.File.ContentLength;
  
          byte[] data = new byte[IG.File.ContentLength];
          IG.File.InputStream.Read(data, 0, IG.File.ContentLength);
  
          IG.ImageData = data;
          using (MitishaKitchenContext dc = new MitishaKitchenContext())
          {
              dc.Images.Add(IG);
              dc.SaveChanges();
          }
          return RedirectToAction("Index");
      }
  </code></pre>
  
  <p>}</p>
  
  <p>How  to  create EDIT method and EDIT Razor View for Image which i stored in database in VARBINARY datatype  in ASP.net MVC? </p>
  
  <p>Here is my Create View:</p>
  
  <pre><code>{
  
   @using (Html.BeginForm("Create","Recipes",null,         FormMethod.Post,new   {enctype="multipart/form-data"}))
          {
            @Html.ValidationSummary(true)
  
  
           &lt;fieldset&gt;
      &lt;legend&gt;Image&lt;/legend&gt;
  
  
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.ImageName)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.ImageName)
          @Html.ValidationMessageFor(model =&gt; model.ImageName)
      &lt;/div&gt;
        &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Recipe.RecipeName)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Recipe.RecipeName)
          @Html.ValidationMessageFor(model =&gt; model.Recipe.RecipeName)
      &lt;/div&gt;
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Recipe.RecipeDescriptions)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.TextAreaFor(model =&gt; model.Recipe.RecipeDescriptions,new {style = "width:90%;height:400px"})
          @Html.ValidationMessageFor(model =&gt; model.Recipe.RecipeDescriptions)
  
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Recipe.RecipeIngredients)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Recipe.RecipeIngredients)
          @Html.ValidationMessageFor(model =&gt; model.Recipe.RecipeIngredients)
      &lt;/div&gt;
  
  
         &lt;br /&gt;
      &lt;table&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Select File : &lt;/td&gt;
                      &lt;td&gt;
                         @Html.TextBoxFor(Model=&gt; Model.File, new{type="file"})
                          @Html.ValidationMessage("CustomError")
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;input type="submit" value="Upload" /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt; 
  enter code here
               &lt;/fieldset&gt;
       }  
  
  }
  </code></pre>