TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
neel k
NA
143
136.9k
System.OutOfMemoryException in mvc 5
Aug 3 2015 12:25 PM
hi,
I got System.OutOfMemoryException, when loading large number of records in mvc 5 application.
controller code:
public ActionResult RunReports(int? id)
{
DomainContext CurrentLoginUser = ActiveDirectory_AccessModel.GetUserDetails(); // Username
GridView gv = new GridView();
var userDetails = (from c in db.SP_GR_Get_Userdetails(CurrentLoginUser.DisplayName)
select c.user_roles).FirstOrDefault();
if (userDetails == null)
{
return RedirectToAction("NoAccess");
}
var runResult = (from c in db.tbl_GR_Reports
where c.Report_ID == id
select c).SingleOrDefault();
TempData["ReportId"] = id;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
if (runResult != null)
{
Microsoft.Practices.EnterpriseLibrary.Data.Database salesworldDbConn = new SqlDatabase(runResult.Db_Connection);
DbCommand cmd = salesworldDbConn.GetSqlStringCommand(runResult.Query);
try
{
ds = salesworldDbConn.ExecuteDataSet(cmd);
}
finally
{
cmd.Dispose();
salesworldDbConn = null;
}
if (ds != null && ds.Tables.Count > 0)
{
dt = ds.Tables[0];
}
}
return View(dt);
}
View Code:
@model System.Data.DataTable
@using System.Data
@{
ViewBag.Title = "RunReport";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<form id="frmRunReport">
<table style="border: 1px solid black;" width="900" align="center">
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td style="font-weight:bold;color:#004b8d; padding-left:20px; font-size:x-large"></td>
</tr>
<tr id="ManageUsers_grid">
<td colspan="2">
<div id="tblExport">
@(Html.Kendo().Grid(Model)
.Name("grid")
.Scrollable(scrollable => scrollable.Virtual(true))
.Columns(columns =>
{
columns.AutoGenerate(column =>
{
column.Width = "100px";
});
})
.HtmlAttributes(new { style = "width: 900px;" })
.Scrollable()
.Filterable()
.Sortable(sortable => sortable.AllowUnsort(true).SortMode(GridSortMode.MultipleColumn))
<input type="button" value="Export to Excel" onclick="@("window.location.href='" + @Url.Action("ExporttoExcel", "Reports", new { id = TempData["ReportId"] }) + "'");" />
</div>
</td>
</tr>
</table>
</form>
.Pageable(pageable => pageable
.PageSizes(true)
)
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
//.PageSize(20)
.ServerOperation(false)
)
)
</div>
</td>
</tr>
<tr>
<td colspan="2" style="vertical-align:central">
<div class="form-footer">
Reply
Answers (
1
)
Dynamically loading and unloading assemblies in ASP.NET MVC
can i add two controller for a single view, provide example.