My Visual Studio 2013 is going crazy , in view I get lot of Error for code Like this :
@Html.LabelFor(model => model.Type, new { @class = "control-label col-md-2" })
And
@Html.TextBoxFor(model => model.Password, new { @class = "form-control" } )
@Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
But when i rebuilt project ,No error will be displayed. And After a few seconds the Errors returns. when i run project , every think alright. But lately I used this code :
<div>
<i class="fa fa-arrow-circle-right"> @Html.ActionLink("go back to list", "Index", "ShowMembers",new {id = int.Parse(ViewData["AdminId"].ToString())},null) </i>
</div>
<li>
@Html.ActionLink("setting", "Index", "AdminSetting", new { id = int.Parse(ViewData["AdminId"].ToString()) }, new { @class = "fa fa-gear fa-fw" })
</li>
And again, i get lot of error for above codes But this time when i run project and i go inside this page i get below error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1520: Method must have a return type
This below lines for action of controller:
public ActionResult Edit(int id = -1,int AdminId = -1)
{
if (Session["AdminId"] != null && Session["AdminName"] != null)
{
repository = new Repository();
var member = repository.FindMemberById(id);
return View(member);
}
else
{
return RedirectToAction("Index", "AdminLogin");
}
}
This is my Source Error:
Line 1294: #line default
Line 1295: #line hidden
Line 1296:BeginContext("~/Areas/Administrator/Views/ShowMembers/Edit.cshtml", 6849, 47, true);
Line 1297:
Line 1298:WriteLiteral("\r\n \r\n
how i solved this?
Authoriseattribute to check if the user is an admin or not. It looks to me that this is what you're trying to do here.