I am building a simple ASP.NET MVC web page that shows all active accounts from MS Dynamics CRM .
Basically, a page works well if I compile and run it (with F5). The problem appears when I go to the Microsoft Dynamics CRM web page, log in, and then change the status of one account from active to inactive. Now, when I refresh the page I create, I get the same old results.
I tried updating (F5), hard updating (Ctrl + F5), deleting the xrm object before returning the view, but nothing xrm . So I think I didn’t understand something.
Controllers /HomeControler.cs
public ActionResult Index() { using (var xrm = new XrmServiceContext("Xrm")) { var accounts = from a in xrm.AccountSet where a.StateCode == 0 select a; List<AccountModel> accountModels = new List<AccountModel>(); foreach (var account in accounts) { Debug.WriteLine(c+"\t"+account.Id+"\t"+account.Name); Debug.WriteLine(account.Address1_Composite); accountModels.Add(new AccountModel( account.Id.ToString(), account.Name, account.Address1_Composite)); } ViewBag.Title = "Page Title"; ViewBag.AccountModels = accountModels; } return View(); }
Views / Home / Index.cshtml
@{ Layout = @"~/Views/Shared/_Layout.cshtml"; } <div class="table-responsive"> <table class="table table-bordered table-condensed table-hover"> <caption><h2>Active Accounts</h2></caption> <thead> <tr> <th>Account ID</th> <th>Account Name</th> <th>Account Address</th> </tr> </thead> <tbody> @{ foreach (var accountModel in ViewBag.AccountModels) { <tr> <td>@accountModel.Id</td> <td>@accountModel.Name</td> <td>@accountModel.Address</td> </tr> } } </tbody> </table> </div>
EDIT: Now I noticed that only the update first after “Reconstruction and Launch” actually updates the site. Is this an IIS Express error (I am doing this locally)?
source share