0

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?

11
  • 2
    What method does it take you to if you click this error message? Does it have a return type? Commented Apr 26, 2016 at 14:28
  • you could probably avoid this by using roles or claims and use the Authorise attribute to check if the user is an admin or not. It looks to me that this is what you're trying to do here. Commented Apr 26, 2016 at 14:39
  • @Spluf , i use this method for all of my page , so its working right Commented Apr 26, 2016 at 14:41
  • is that the error you get every time? have you tried debugging to see which method throws that error? your controller looks fine, your razor as well... Commented Apr 26, 2016 at 14:44
  • I debugged, my controllers are fine Commented Apr 26, 2016 at 14:52

1 Answer 1

1

I use two }} in below line :

@Html.LabelFor(model => model.Type,  new { @class = "control-label col-md-2" }})

correct is below line:

@Html.LabelFor(model => model.Type,  new { @class = "control-label col-md-2" })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.