asp.net mvc - url.action, jquery, and mvc -


i'm building application shutdown server, ping server, , notify user if server has been shutdown. if not shutdown successfully, allows user "try again". can application process logic correctly first time when implement "try again" feature, not reprocess shutdown action. think must have caching don't know enough know start looking. ideas?

here code:

controller

    //url: build/progress       public actionresult progress()       {           return view();       }    ////url: build/movedevice   public actionresult shutdownstatus()   {       imageinfo imageinfo = new imageinfo();       farminfo farminfo = new farminfo();       progressmodel progressmodel = new progressmodel();        if ((session["shutdownstatus"] string) == "success")       {           progressmodel.shutdownstatus = 1;           return view(progressmodel);       }       else       {           imageinfo = svcimage.getimageinfobyimageid(session["imagename"].tostring());           string farm = imageinfo.farmid.tostring();           farminfo = svcfarm.getfarmbyfarmid(farm);           svcimagesvc.shutdowndevice(session["username"].tostring(), session["password"].tostring(), session["domain"].tostring(),               farminfo.farmname, imageinfo.device, imageinfo.imagehistory.status, imageinfo.pvshost, imageinfo.pvsaccount);            progressmodel.shutdownstatus = svcimagesvc.pingdevice(imageinfo.device);           return view(progressmodel);       }   } 

views (progress.aspx)

<%@ page title="" language="c#" masterpagefile="~/views/shared/site.master" inherits="system.web.mvc.viewpage<dynamic>" %>    <asp:content id="content1" contentplaceholderid="titlecontent" runat="server">       progress   </asp:content>    <asp:content id="content5" contentplaceholderid="headcontent" runat="server">    </asp:content>    <asp:content id="content2" contentplaceholderid="maincontent" runat="server">       <h1>progress</h1>       <hr />        <!-- shutdown status -->       <div class="panel" id="panel1"><img src="../../assets/images/load.gif" /></div>       <script type="text/javascript">           $.get('<%= url.action("shutdownstatus", "build", null) %>',           function (data) {               $('#panel1').replacewith(data);           });       </script>    </asp:content>    <asp:content id="content3" contentplaceholderid="headercontent" runat="server">   </asp:content>    <asp:content id="content4" contentplaceholderid="footercontent" runat="server">   </asp:content> 

view (shutdownstatus.asxc)

<%@ control language="c#" inherits="system.web.mvc.viewusercontrol<pvsutil.app.core.models.progressmodel>" %>        <% using (html.beginform())          { %>           <% if (model.shutdownstatus == 1)              { %>              <%: session["shutdownstatus"] = "success" %>               <p>                   server shutdown succesfully               </p>               <% } %>            <% if (model.shutdownstatus == 2)               { %>               <p>server did not shutdown within 1 minute.  please check server , try again.</p>               <%: html.actionlink("try again", "progress", "build") %>               <% } %>            <% if (model.shutdownstatus == 3)           { %>           <p>an error has occurred.  please check server , try again.</p>           <%: html.actionlink("try again", "progress", "build") %>           <% } %>        <% } %>   

i believe caching being done jquery. change $.get $.post , see if works. if does, can still use $.get, need set option:

cache: false 

hth, brian


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -