c#


MVC not consistently returning view


I have a view in my MVC site that seems to intermittently stop working, despite the controller code running through fine and the razor code on the view itself running through fine. The view works most of the time, but occasionally (this morning for example) it just stopped randomly for about an hour and then started again just as randomly.
Controller
The controller that returns the view simply runs a SQL procedure that returns counts of rows based on their status, something along the lines of:
Select
FaultStatus,
count(*) as StatusCount
From
tblfaults
Group By
FaultStatus
With the controller itself running the following code to run the procedure and return the data, which is then converted into a list that is passed to the view:
private IEnumerable<T> ReadData<T>(string storedProcedure, string connection, Func<SqlCommand, SqlCommand> buildCommand, Func<NortonSqlDataReader, T> readRecordMethod)
{
var records = new List<T>();
using (var sqlConnection = new SqlConnection(connection))
{
sqlConnection.Open();
using (var sqlCommand = new SqlCommand(storedProcedure, sqlConnection))
{
sqlCommand.CommandType = CommandType.StoredProcedure;
buildCommand(sqlCommand);
using (var sqlDataReader = new NortonSqlDataReader(sqlCommand.ExecuteReader()))
{
while (sqlDataReader.Read())
{
records.Add(readRecordMethod(sqlDataReader));
}
}
}
}
return records;
}
View
The view has the following code, which loops through the records and returns a coloured panel for each one depending on how many there are for that particular status. This is reloaded every so often so that the numbers are kept up to date:
#model IEnumerable<Monitor.Models.Fault.StatusCount>
<div id="summary">
#foreach (var item in Model)
{
if (item.Count <= 3)
{
<div id="summary_#item.FaultStatus" class="Summary-Green">
#{
var text = "";
if (item.FaultStatus == "new")
{
text = item.Count + " New Jobs";
}
else if (item.FaultStatus == "pending")
{
text = item.Count + " Pending Jobs";
}
else if (item.FaultStatus == "onhold")
{
text = item.Count + " On Hold Jobs";
}
}
<b>#Html.ActionLink(text, "Index", "Home", new {Status = item.FaultStatus}, new {style = "color: #000000;", target = "_blank"})</b>
</div>
}
else if (item.Count <= 7)
{
<div id="summary_#item.FaultStatus" class="Summary-Yellow">
#{
var text = "";
if (item.FaultStatus == "new")
{
text = item.Count + " New Jobs";
}
else if (item.FaultStatus == "pending")
{
text = item.Count + " Pending Jobs";
}
else if (item.FaultStatus == "onhold")
{
text = item.Count + " On Hold Jobs";
}
}
<b>#Html.ActionLink(text, "Index", "Home", new {Status = item.FaultStatus}, new {style = "color: #000000;", target = "_blank"})</b>
</div>
}
else
{
<div id="summary_#item.FaultStatus" class="Summary-Red">
#{
var text = "";
if (item.FaultStatus == "new")
{
text = item.Count + " New Jobs";
}
else if (item.FaultStatus == "pending")
{
text = item.Count + " Pending Jobs";
}
else if (item.FaultStatus == "onhold")
{
text = item.Count + " On Hold Jobs";
}
}
<b>#Html.ActionLink(text, "Index", "Home", new {Status = item.FaultStatus}, new {style = "color: #000000;", target = "_blank"})</b>
</div>
}
}
</div>
</body>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
setInterval(function () {
location.reload();
}, 30000);
});
</script>
In debug mode I can step through each part of the code in the controller and the view, and at each step there are no errors and it has the data that is expected. But once everything has finished loading the view just displays a blank page with nothing (not even any underlying html that i've entered) showing at all. I have tried just putting a random piece of text in and it doesn't work either.
What I have noticed however is that if I comment out everything, put in some random text or anything, and then reload, then it does show what i've entered. So i'm not sure if somehow the razor on the page is stopping it from loading. I thought at first that maybe the data was somehow breaking it, but that doesn't seem to be the case.

Related Links

JToken.ToString() removing curly braces
How to reference a project out of solution?
Wpf collapse item in ItemsControl with animation (slideToggle for example)
prevent outputcache if request contains specific header-info
Adding a new object to a SQL Server database using LINQ C#/MVC does simply returns me to the same page without adding records to the database
After updating Mvvm Light to Version 5, what changes do I need to make RelayCommand CanExecute() work?
Textbox remembers its data on page refresh
C# Match User Inputs to Array
NullReferenceException throw by CompletionPortCallback
Outlook 2010 AppointmentItem getting all reuccurence appointments
Protected function not accessible in derived class
how to redirect from a page in a folder to the page in root directory?
Boolean to integer conversion
C# fire event when database connection fails for 5 seconds
Checking if a string contains words in a specific order
Null DateTime variable

Categories

HOME
primefaces
cors
grpc
window.open
boxplot
ubuntu-14.04
artifactory
ebay
samsung-gear-s2
google-my-business-api
openstack-horizon
luis
internet-explorer-7
openam
orange
beacon
url-parameters
xna
ejb-3.1
v4l2
rollupjs
marionette
ocl
folder
akamai
opencsv
ports
eclipse-jdt
jsonapi-resources
angularjs-resource
http-proxy
extern
julia-jump
flume-ng
text-extraction
gradlew
ocpjp
stanford-nlp-server
ng-class
riemann
gige-sdk
programming-pearls
nsalert
multi-select
alfred
hoare-logic
diameter-protocol
chomsky-normal-form
std
apache2-module
controlpanel
webservices-client
javapackager
php-gd
biginsights
cloud-storage
pagecontrol
sparkcore
playn
opennebula
bungeecord
shunting-yard
nsq
aiff
system.io.packaging
worklight-appcenter
fscanf
step
scjp
ant-contrib
jsmpp
farpoint-spread
db2-connect
usersettings
pyxplot
wpd
spawn
pymel
ntdll
gssapi
hypertable
certificate-revocation
github-archive
dancer
nsscrollview
automapper-2
funambol
object-tag
simultaneous
browser-state
silverlight-2.0
pkcs#7
file-icons
bootstrap-protocol

Resources

Encrypt Message