0

In my controller in MVC I have a method ParseAndWrite() which is called twice. Initially my view was like following.

   @model dynamic
   @{
     ViewBag.Title = "title";
     Layout = "_Layout";
   }
   <h2>title</h2>
   @Html.ActionLink("Push me","ParseAndWrite","JsonDeserialize") 

then I read this post MVC controller is being called twice and I tried to change it like following:

@model dynamic

@{
  //ViewBag.Title = "title";
  //Layout = "_Layout";
}

<h2>title</h2>

but anyway this is not working,and I tried to change return to null, and new EmptyResult() in my controller method but it doesn't work . Controller Method code:

    public ActionResult ParseAndWrite()
    {
        JsonDeserializeHelper.WriteTransportCategories();
        JsonDeserializeHelper.WriteBusClasses();
        JsonDeserializeHelper.WriteTransportCurrectCategoryTypes();
        JsonDeserializeHelper.WriteBusModelSpecs();
        JsonDeserializeHelper.WriteBusModels();
        JsonDeserializeHelper.WriteBusModelSpecValues();


        return View();
    }
Community
  • 1
  • 1
Abbath
  • 1,002
  • 13
  • 30
  • 1
    Have you tried using the browser debugging tools (F12) to see when the calls are being made (network tab). This might yield a clue as to what is calling the controller. – Justin Harvey Sep 30 '13 at 08:17
  • 1
    When exactly is this action called twice? From your second attempt with the view it seems the button has nothing to do with it? Is there maybe some javascript also on that page? – DrCopyPaste Sep 30 '13 at 08:30
  • @no there is not java script this link, this like only get data in json and write in db. Page must be empty. – Abbath Sep 30 '13 at 08:41

0 Answers0