I'm having an issue. I've developed a simple CMS using ASP.NET Web Pages 3.2 Framework, it's developed in Razor C#. The CMS works fine when I'm testing using the system, but I've now extracted it to a website which will be using this CMS, so I generated the tables and all, and it should all work. Everything seems to work, except for the code below. It works completely fine in the CMS itself, but when using it on the other website, it comes up with an error saying "Object reference not set to an instance of an object", and it highlights my array.
I am somehow suspecting it has something to do with the way I generated the scripts etc., but I don't see how I could have done that wrong. I've been trying to fix the issue, but I just can't seem to figure out what's wrong, and it's driving me mad.
<table class="accounts-table">
<tr>
<th>Username</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Role</th>
<th>Actions</th>
</tr>
@foreach (var row in db.Users)
{
string[] roleName = Roles.GetRolesForUser(row.UserName);
<tr>
<td>@row.UserName</td>
<td>@row.FirstName</td>
<td>@row.LastName</td>
<td>@foreach (var role in roleName) { @role } </td>
<td>
<a href="~/Admin/Pages/Accounts/View?UserID=@row.UserId" title="View"><span class="fa fa-user"></span></a>
<a href="~/Admin/Pages/Accounts/Edit?UserID=@row.UserId" title="Edit"><span class="fa fa-edit"></span></a>
<a href="~/Admin/Pages/Accounts/Delete?UserID=@row.UserId" title="Delete"><span class="fa fa-remove"></span></a>
<a href="~/Admin/Pages/Accounts/Lock?UserID=@row.UserId" title="Lock"><span class="fa fa-lock"></span></a>
</td>
</tr>
}
</table>